As always namespaces and XPath/XSLT is “funny” to play around with. Tonight I have been messing a little with the ATOM feeds available in Lotus Connections and needed to use XPath to extract a URL from the service document instead of the object model in Abdera. I didn’t find it all together easy to figure out so I’ll post it here in case it helps anyone. The key is to specify a java.util.Map with the two namespaces in use (atom, app) when doing the XPath (the “ns” variable) and remembering to use the correct namespaces in the actual XPath string.
Document<Service> doc = ...; XPath x = Abdera.getNewXPath(); Map ns = new HashMap(); ns.put("atom", "http://www.w3.org/2005/Atom"); ns.put("app", "http://www.w3.org/2007/app"); String link = x.valueOf("/app:service/app:workspace" + "/atom:link[@rel='http://www.ibm.com/xmlns/prod/sn" + "/mv/theboard']/@href", service, ns)); System.out.println("Link: " + link);