Wednesday, November 30, 2005

Default Namespace in XPath

To access the different nodes within the cosmos with an XPath I use an XPath processor. Unfortunatly XPath 1.0 does not allow to specify the default namespace. To distinguish cosmos object nodes from other, more general content within the objects I like to put them into a specific namespace. So either all the IDs (tag names) of the cosmos objects need to be prefixed (eg. '' or we are restricted to XPath 2.0, which allows to specify the default namespace.
Since JAXP 1.3 only offers XPath 1.0 this implemention becomes dependent on the processor implementaion (Saxon 8.6.1B for now). The default namespace can be set with net.sf.saxon.xpath.StandaloneContext.setDefaultElementNamespace().

No comments:

Post a Comment