Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] adding NamespaceContext.getNamespaces()

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] adding NamespaceContext.getNamespaces()
  • Date: Tue, 31 Oct 2006 07:49:36 -0800

I'd really love to reuse nu.xom.XPathContext for XQuery, but to do so realistically one needs a way to get hold of the entire set of stored namespace declarations. For simplicity, I'd advocate to add a single corresponding method to XPathContext:

/**
* Returns the namespace declarations stored in this context.
*
* @return an unmodifiable map of prefix --> URI associations
* where prefix and URI are non-empty strings.
*/
public Map getNamespaces() {
return Collections.unmodifiableMap(this.namespaces);
// return new HashMap(this.namespaces); // less efficient
}

Assuming that happens, it might be considerable to remove the public XPathContext.lookup() method as mostly obsolete - if needed it can be expressed in terms of getNamespaces(). I think there's no compatibility issue since lookup() was only tentatively added in the 1.2 beta series.

Wolfgang.

Being able to iterate over things does make working with XML easier:

for(Node n:message.xpath("muws-p2-xs:StateTransition/*", catalog)) {
SoapElement e=(SoapElement) n;
//act on the element
}
-steve





Archive powered by MHonArc 2.6.24.

Top of Page