Using Abdera XPath on the Lotus Connections service document

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);

Published by

lekkim

Positive, competent, out-spoken, frank and customer focused architect and developer with a strong foundation in web, cloud and product development. I'm a strong advocate for API first and cloud based solutions and development. I have a knack for being able to communicate and present technically complicated matters in conference, customer and training settings. I've previously acted as team member and leader in a product organisation.

One thought on “Using Abdera XPath on the Lotus Connections service document”

  1. Thanks!

    Great tip, for newbies to XPath, Adbdera and Connections (like my self) from the code above the only missing bit is

    Service s = doc.getRoot();

    Right after you instantiate doc

Comments are closed.