Hi Carla, The code you're looking at is Sun's fork of the codebase. Apache Xerces has never called into org.apache.xml.serializer.TreeWalker to do the traversal. The implementation in Xerces (since 2.7.0 when it was introduced) was written so that it is capable of validating Nodes from a DOM Level 2 implementation. It currently doesn't call any methods (such as isSameNode()) that are only available in DOM Level 3. There was a similar issue in the DOM Level 2 TreeWalker [1] which I fixed [2] last year. The same fix could be applied here.
Thanks. [1] http://issues.apache.org/jira/browse/XERCESJ-1127 [2] http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/TreeWalkerImpl.java?revision=371588&view=markup Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] "Carla Spruit" <[EMAIL PROTECTED]> wrote on 05/09/2007 04:59:08 AM: > Hi, > > We would like to use the Xerces validation implementation to > validate a DOM Document. > (see http://xerces.apache.org/xerces2- > j/javadocs/api/javax/xml/validation/Validator.html) > > In Xerces 2.6.2 (included with java 1.5.0) the org.apache.xml. > serializer.TreeWalker traverse method is used to traverse the DOM > structure during validation. > > The following piece of code of this class shows that nodes are > compared by using the equals method: > > public void traverse(Node pos) throws org.xml.sax.SAXException { > this.m_contentHandler.startDocument(); > Node top = pos; > while (null != pos) { > startNode(pos); > Node nextNode = pos.getFirstChild(); > while (null == nextNode) { > endNode(pos); > if (top.equals(pos)) > break; > > ?.. > } > > I do not exactly know when this is changed, but at least from Xerces > 2.7.1, the org.apache.xerces.jaxp.validation.DOMValidatorHelper > validate method now handles the traversal of the DOM Document. > Unfortunately, the node test ?top.equals(pos)? is now replaced by > the test ?top == pos?. Our DOM implementation does not work with the > ?==? comparison so we can no longer use the validation API to > validate DOM structures. We are aware of the fact that the DOM specs > do not say anything about node comparisons except the DOM level 3 > functions isSameNode and isEqualNode. > Is there any other way to validate DOM structures with XML Schema > without modification of the DOM document and without serializing and > reparsing the document? (the DOM level 3 normalizeDocument function > is not an option because it may modify the DOM). > > We would also like to be able to filter out nodes before validation. > I have read the http://marc.info/?l=xerces-j-user&m=117758843732534&w=2 > conversation but was unable to find a way to validate a ?filtered? > DOM structure. > > Is there any chance that you will change the validation traversal > behavior in the near future? > > Thanks, > > Carla Spruit --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]