I'd probably be safe to assume this is the infamous namespace issue. Check out the bottom two here: http://jaxen.org/faq.html
This issue really irritates me and I'm about to send my original mailing list message that was never responded to to all the Jaxen developer emails. I'll include that text at the end of this email. Alternatively, you can do what I do: /** *Removes namespaces if removeNamespaces is true */ public static void fixNamespaces(Document doc){ Element root = doc.getRootElement(); if(removeNamespaces && root.getNamespace() != Namespace.NO_NAMESPACE) removeNamespaces( root.content() ); } /** *Puts the namespaces back to the original root if removeNamespaces is true */ public static void unfixNamespaces(Document doc, Namespace original){ Element root = doc.getRootElement(); if(removeNamespaces && original != null) setNamespaces(root.content(), original); } /** *Sets the namespace of the element to the given namespace */ public static void setNamespace(Element elem, Namespace ns){ elem.setQName( QName.get( elem.getName(), ns, elem.getQualifiedName() ) ); } /** *Recursively removes the namespace of the element and all its children: sets to Namespace.NO_NAMESPACE */ public static void removeNamespaces(Element elem){ setNamespaces(elem, Namespace.NO_NAMESPACE); } /** *Recursively removes the namespace of the list and all its children: sets to Namespace.NO_NAMESPACE */ public static void removeNamespaces(List l){ setNamespaces(l, Namespace.NO_NAMESPACE); } /** *Recursively sets the namespace of the element and all its children. */ public static void setNamespaces(Element elem, Namespace ns){ setNamespace(elem, ns); setNamespaces(elem.content(), ns); } /** *Recursively sets the namespace of the List and all children if the current namespace is match */ public static void setNamespaces(List l, Namespace ns){ Node n = null; for(int i=0; i<l.size(); i++){ n = (Node)l.get(i); if(n.getNodeType() == Node.ATTRIBUTE_NODE) ( (Attribute)n ).setNamespace(ns); if(n.getNodeType() == Node.ELEMENT_NODE) setNamespaces( (Element)n, ns ); } } Email to Jaxen people: I know it may not be a part of the XPath spec, but is there any way the developers would consider some mechanism to bypass all the namespace hassles? For my purposes, I'm only using XHTML documents, which are given a namespace by the DTD in dom4j, so I can't use the default namespace. It would be VERY nice if there was some way to turn off namespaces or setup an override that maps unspecified namespaces in an XPath expression to a given uri, or have a setting that uses the context node's(or root node's) namespace if one isn't specified in the expression. If not, could you tell me where in the code I could make a change like this. It's significant enough that I'd consider maintaining a patched version. I tried fiddling with it, but nothing that looked promising was even running when evaluating my test expression. --Evan foo monkey wrote: > I am working on an XML project and wanting to use dom4j. I have > things working it seems. When I decided to use XPath, I found that I > also need Jaxen. So, I downloaded that, put it on the classpath and it > seems to work. Is this requirement documented somewhere? I confess > that I've not fully read all the docs so flame me if you'd like :) . > > My other problem though is when I try to bundle this code up in a JEE > app and deploy it to a WebSphere Application Server. My app is happy > with the dom4j calls. But, when I try to do any XPath stuff using > Jaxen, it just doesn't work. It doesn't seem to be raising any > exceptions. I just get NULL when I do a > node.selectSingleNode("//element") call. > > Any ideas on how I might be able to resolve this one? Thanks to all > for a very cool (and free!) parser. > > Thanks. > Andrew > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user