#288 Retrieving base URI fails with JDOM

v8.2
closed
Michael Kay
5
2012-10-08
2005-01-06
Michael Kay
No

When retrieving the base URI of a node (for example to
support the document() function, or to support the
base-uri() function), when the node is in a JDOM tree,
Saxon fails with a JDOM error

org.jdom.IllegalNameException: The name
"http://www.w3.org/XML/1998/namespace" is not legal for
JDOM/XML

Source fix: in net.sf.saxon.jdom.NodeWrapper, change
method getAttributeValue () (line 619) to:

public String getAttributeValue(int fingerprint) {
if (nodeKind==Type.ELEMENT) {
NamePool pool = docWrapper.getNamePool();
String uri = pool.getURI(fingerprint);
String local = pool.getLocalName(fingerprint);
return ((Element)node).getAttributeValue(local,
( uri.equals(NamespaceConstant.XML) ?
Namespace.XML_NAMESPACE :
Namespace.getNamespace(uri)));
// JDOM doesn't allow getNamespace() on
the XML namespace URI
}
return null;
}

Applies to 8.2 and all earlier releases, when used with
JDOM 1.0.

Discussion