[jdom-interest] [Q]Problem at the search JDOM with JaxenXPath
Itoh, Kazuhiro
kazuhiro-i at kajima.com
Thu Nov 7 02:55:41 PST 2002
Dear All
This is kazuhiro from Japan.
Now I am trying to develop the System with Xindice, JDom and JaxenXPath.
I met the trouble at XPath search with Namespace.
Source code fragment is here.
--------------------- start ----------------------------
while(results.hasMoreResources()) {
Resource res = results.nextResource();
if (res.getResourceType().equals("XMLResource")) {
XMLResource xmlres = (XMLResource)res;
org.w3c.dom.Node root = xmlres.getContentAsDOM();
org.w3c.dom.Document dom = root.getOwnerDocument();
jdom = builder.build(dom);
//Create Jaxen
xpath = new JDOMXPath("/M7:problem/@M7:description");
xpath.addNamespace(prefix, url);
//
elm = (Element)xpath.selectSingleNode(jdom);
System.out.println(" : " + elm.getTextTrim());
/*
org.w3c.dom.Node desc =
org.apache.xpath.XPathAPI.selectSingleNode
(root, "M7:problem/M7:description", root);
System.out.println("Description :" +
desc.getFirstChild().getNodeValue().trim());
*/
}
}
--------------------- End -------------------------------------
XPath w/o namespace works well. But XPath w/ namespace dose not work
well.
Is there any bug using JaxenXPath.
Yes I understand this is the JDom world. But I got Jaxen from this
mailing-list.
Please show me any resolution.
P.S.
The comment-out code works well.
Thanks.
kazuhiro
More information about the jdom-interest
mailing list