Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] unexpected xpath result with default namespace part 2

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Jan <janreimone AT gmail.com>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] unexpected xpath result with default namespace part 2
  • Date: Sun, 09 Aug 2009 10:27:45 +0200

Yesterday I posted the same problem. With help of Michael Kay and
http://www.edankert.com/defaultnamespaces.html I got it solved.

Element schema = doc.getRootElement();
XPathContext xpathContext = XPathContext.makeNamespaceContext(schema);
String emptyNS = xpathContext.lookup("");
String baseNS = schema.getNamespaceURI();
if(baseNS != null && baseNS.equals(emptyNS)){
xpathContext.addNamespace("myprefix", baseNS);
}

Then a query must look like this:

//myprefix:COMMON




Archive powered by MHonArc 2.6.24.

Top of Page