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/Val
idator.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

 

 

 

 

 

 

Reply via email to