Project

Profile

Help

Standalone sxpath problem (new to saxon)

Added by Anonymous over 17 years ago

Legacy ID: #4059227 Legacy Poster: Tom (javerra66)

I am attempting to use the standalone xpath api since it will work with my current Java level 1.4 However, evaluating any xpath expression other than the root "." returns an empty list. Here is a bit of my code. import net.sf.saxon.sxpath.*; import javax.xml.transform.Source; StringReader reader = new StringReader(<my xml document as a string>); parser.parse(new InputSource(reader)); document = parser.getDocument(); //SAXON CODE XPathEvaluator xpe = new XPathEvaluator(); XPathExpression xps = xpe.createExpression("//IdValue"); Source source = new DOMSource(document); List results = xps.evaluate(source); There are IdValue elements in the document so these should be returned in the list, correct? any help would be appreciated!


Replies (1)

RE: Standalone sxpath problem (new to saxon) - Added by Anonymous over 17 years ago

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

You haven't shown your XML Source, but the most likely explanation for //IdValue not selecting anything is that the IdValue elements are in a namespace (probably the default namespace). If so, try calling xpe.setDefaultElementNamespace("namespaceuri")

    (1-1/1)

    Please register to reply