cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Homeijer <>
Subject Rewrite XMLDBTransformer or wait for dispatcher interface
Date Fri, 15 Feb 2002 08:25:10 GMT

I am preparing for a project where commands have to be added to the
XMLDBTransformer. The way it's currently written this will become more and
more complex.
I am thinking of implementing inner classes that handle a specific
tag/command. The inner class will capture/influence part of the SAX stream.

Current XMLDB Implementation will then contain 3 command classes:
XMLDBCommandDelete, XMLDBCommandUpdate and XMLDBCommandCreate. 

The XMLDBCommandDelete class will become as follows:

private class XMLDBCommandDelete extends TransformerCommand {

    public void startCommand(String uri, String loc, String raw, Attributes
    throws SAXException {
	super.startCommand(uri, loc, raw, Attributes a);
	this.key = a.getValue(XMLDB_QUERY_OID_ATTRIBUTE);

	if(this.key == null) {
		throw new SAXException("Object ID is mandatory in xmldb
delete query");

	public void endCommand(String uri, String loc, String raw)
		throws SAXException {
		String result;
		String message = null;

		Resource resource = collection.getResource(this.key);
		if (resource == null) {
			message = "Resource " + this.key + " does not
		} else {
		result = "success";

		AttributesImpl attrs = new AttributesImpl();
		attrs.addAttribute(null, XMLDB_QUERY_OID_ATTRIBUTE,
		attrs.addAttribute(null, XMLDB_QUERY_TYPE_ATTRIBUTE,
		attrs.addAttribute(null, XMLDB_QUERY_RESULT_ATTRIBUTE,
		consumer.startElement(uri, loc, raw, attrs);
		if (message != null) {
			consumer.characters(message.toCharArray(), 0,
		consumer.endElement(uri, loc, raw);

Once this works, few ancestor classes can be created to simplify writing
transformers that use these commands.
I have seen the Ldap transformer as an alternative but it will still be
difficult en probably causing errors if normal developers have to add
commands to the transformers or write their own.

Is this the way to go or should I wait for/work with the dispatcher
interface that was mentioned a few days ago?

Michael Homeijer

To unsubscribe, e-mail:
For additional commands, email:

View raw message