I know Xalan only permits DOM to be used in its XPathFactory but I'm hoping that the developers will know what the correct way to use a different object model is.

How to use a different object model has been confusing me for a while. I understand that by default DOM is used and that if I wanted to use a different object model then I can do so by supplying a different URI to the XPathFactory. However what I don’t understand is what can I do with it.

The API explicitly states that only return types from java.xml.xpath.XPathConstants may be used. XPathConstants is also a final class. This suggests to me that you cannot create your own return types since if you were to follow the API, on evaluation an IllegalArgumentException should be thrown.

Therefore how am I meant to work with my object model specific constructs?

Say I am evaluating an expression that returns a node-set and the representation of the node-set in my model is a java.util.List. Am I allowed to do the following:

MyDocument doc = …;
 
XPathFactory factory = XPathFactory.newInstance( http://myobjectmodel );
XPath xpath = factory.newXPath( );
 
String expr = “/book/chapter”;
List nodes = ( List ) xpath.evaluate( expr, doc, XPathConstants.NODESET );



If I am, then why do the javadocs explicitly state that XPathConstants.NODESET maps to org.w3c.dom.NodeList? Should it not say, for the DOM URI it maps to a NodeList?

If I can’t, then does that mean I need to provide an adapter from my object model to W3C DOM?

Thanks in advance,

Jeff


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to