[jdom-interest] [Q]Problem at the search JDOM with JaxenXPath
Laurent Bihanic
laurent.bihanic at atosorigin.com
Thu Nov 7 07:31:49 PST 2002
Hi,
The XPath expressions used with Jaxen and Apache XPath are different
(M7:description is declared as an attribute with Jaxen (/@M7:description) and
as a child element with Apache (/M7:description)). Couldn't that be the source
of the problem?
Laurent
Itoh, Kazuhiro wrote:
> 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