Hi, 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 a) 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 exist"; } else { collection.removeResource(resource); } result = "success"; AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute(null, XMLDB_QUERY_OID_ATTRIBUTE, XMLDB_QUERY_OID_ATTRIBUTE, "CDATA", this.key); attrs.addAttribute(null, XMLDB_QUERY_TYPE_ATTRIBUTE, XMLDB_QUERY_TYPE_ATTRIBUTE, "CDATA", this.operation); attrs.addAttribute(null, XMLDB_QUERY_RESULT_ATTRIBUTE, XMLDB_QUERY_RESULT_ATTRIBUTE, "CDATA", result); consumer.startElement(uri, loc, raw, attrs); if (message != null) { consumer.characters(message.toCharArray(), 0, message.length()); } 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? TIA, Michael Homeijer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]