On Tue, 2005-03-01 at 14:15 +1300, Simon Kitching wrote: > Hi Kristian, > > On Mon, 2005-02-28 at 17:43 +0100, Kristian Mandrup wrote: > > Added PREFIX namespace support for NodeCreateRule: Can now parse a XML > > Schema correctly â > > Tested (see Junit TestCase below). Works fine! > > [snip] > > > if ((localName == null) || (localName.length() == 0)) { > > top = doc.createElement(qName); > > } else { > > top = doc.createElementNS(namespaceURI, localName); > > } > > String prefix = qName.split(":")[0]; > > if (prefix != null) { > > top.setPrefix(prefix); > > } > > This seems to ensure that if an xml document containing namespaces is parsed > with > a non-namespace-aware xml parser (ie localName is not defined), then a DOM-1 > (ie non-namespace-aware) element node is created ("createElement"), but then > the namespace-aware "setPrefix" method is called on it. > > It seems to me that if the createElement (ie non-namespace-aware) method > is called to create the attribute, then calling setPrefix (ie a > namespace-aware method) is a bad idea. A prefix is being set, but there > is no namespace URI associated with the node...
Ok, I've had another look and think I understand at least part of your patch. First, you've added support for NodeCreateRule to the xmlrules module. That's fine - though providing an explicit patch to do *just* this (including a patch to the dtd and some unit tests) would be preferable to including this as part of a larger and more complex patch. By "patch" I mean a file generated by "svn diff ....", which generates a diff file between your local version (with the changes in it) and the current version in the apache subversion repository. I would also recommend leaving out the rather complex code that allows the xmlrules to specify configuration for a custom DocumentBuilderFactory; I'm not convinced that this is necessary or useful, and leaving it out of your initial patch will make it more likely that the initial patch will be merged in a timely manner. You're then trying to parse a document containing namespaces, using a namespace-aware parser. But a pattern can never match an xml element which has a namespace unless the "setNamespaceURI" method has been called on the Rule object (either directly, or indirectly via Rules.setNamespaceURI or Digester.setRuleNamespaceURI). Note that the setRuleNamespaceURI method used in your testcase has no effect: Digester d = DigesterLoader.createDigester(rules); d.setNamespaceAware(true); d.setRuleNamespaceURI("www.diku.dk"); That method only affects rules added after the call is made; but by the time you call it here, all the rules have already been added. In fact, there is currently no way to use the "setNamespaceURI" functionality with xmlrules as far as I can see. If you would like to provide a patch to add that to xmlrules somehow, that would be nice. I can't suggest how, though. And you'd certainly need to read the RulesBase implementation of the match(namespace, name) method to understand how Digester's horribly hacky implementation of namespace support currently works. I still don't understand the point of the changes to the NodeCreateRule; see my comments in the previous email. Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]