Project

Profile

Help

Saxon 8.1: Default namespace and XPath

Added by Anonymous over 19 years ago

Legacy ID: #2928919 Legacy Poster: Yana Kadiyska (ykadiyska)

Hi, I am trying to evaluate an XPath expression over an xml doc with a default namespace. declareNamespace() in StandaloneContext works great but not for the "" prefix. There is a function setDefaultFunctionNamespace(java.lang.String uri), but I don't see an equivalent setDefaultElementNamespace I saw an old thread on this and it appears that declaring a prefix and modifying the query solves the issue, but I have no control of the queries (they come over the wire)--e.g I want to say //b rather than //s:b, where element b is in the default ns Any help/advice much appreciated


Replies (1)

RE: Saxon 8.1: Default namespace and XPath - Added by Anonymous over 19 years ago

Legacy ID: #2928946 Legacy Poster: Michael Kay (mhkay)

For some reason StandaloneContext doesn't provide the ability to set a default element namespace. I don't think there's any technical reason for this, it's just something that I never got round to, because it hasn't been requested. The getDefaultElementNamespace() method always returns the no-namespace, as it would in XPath 1.0. I'll add this capability, but in the meantime, I suggest you subclass StandaloneContext so that getDefaultElementNamespace returns a value that you can set.

    (1-1/1)

    Please register to reply