[jdom-interest] Attribute namespaces

Kevin Stadlmayer kstadlmayer at mpowertech.com
Wed Oct 4 17:38:56 PDT 2000


I've been trying to build a JDOM document out of a somewhat complex XML
string (multiple namespaces, etc.).  I have checked this XML String, and it
is well-formed (all the required namespaces are listed).  

I am using the following code to generate a Xerces formatted
org.w3c.dom.Document, which I am then trying to change into a JDOM Document:

         (assuming we pass in a String of XML, xml)

         StringReader reader = new StringReader(xml);
         InputSource input = new InputSource(reader);

         org.apache.xerces.parsers.DOMParser parser = new
         parser.setFeature("http://xml.org/sax/features/validation", true);
         parser.setFeature("http://xml.org/sax/features/namespaces", true);
         org.w3c.dom.Document doc = parser.getDocument();

         // convert XmlDocument to JDOM Document to allow for easier
         DOMBuilder dom = new

         Document doc = dom.build( doc );

Unfortunately, I get a SAXParserException at this line.  The message is:
"The name "b:dt" is not legal for JDOM/XML attributes: : is not allowed in
XML names.."

The attribute "dt" belongs to a namespace that is represented by the prefix
"b", and it is a part of an element that belongs to a different namespace.
The actual element in the XML String is:

<f:foldersize b:dt="int">1126</f:foldersize>

DOMBuilder doesn't seem to have a problem with the element namespaces.

Has anyone seen this before?  Is this something that may have been fixed for
Beta 5?  Or am I just using it plain wrong?


Kevin Stadlmayer

More information about the jdom-interest mailing list