[XOM-interest] "Additional namespace" Exception using XMLReader

Edwin Dankert edankert at gmail.com
Tue Aug 21 10:17:02 EDT 2007


I noticed the following strange behavior.

The following exception occurs:

"Additional namespace http://www.edankert.com/test for the prefix test
conflicts
with existing namespace binding"

This happens when constructing the Builder with a XMLReader (constructed
using JAXP) and then providing the builder with the following XML to build:

<test xmlns:test="http://www.edankert.com/test" test:attribute="whatever"/>

This is where it all goes wrong:

<code>
StringReader reader = new StringReader(
    "<test xmlns:test=\"http://www.edankert.com/test\"
test:attribute=\"whatever\"/>");

Builder builder = new Builder(
    SAXParserFactory.newInstance().newSAXParser().getXMLReader());
builder.build(reader);
</code>

The following cases however do not give any problems:

<code>
StringReader reader = new StringReader(
    "<test xmlns:test=\"http://www.edankert.com/test\">"+
        "<child test:attribute=\"whatever\"/>"+
    "</test>");

Builder builder = new Builder(
    SAXParserFactory.newInstance().newSAXParser().getXMLReader());
builder.build(reader);
</code>

<code>
StringReader reader = new StringReader(
    "<test xmlns:test=\"http://www.edankert.com/test\"
test:attribute=\"whatever\"/>");

Builder builder = new Builder();
builder.build(reader);
</code>

Kind regards,
Edwin
-- 
http://www.edankert.com/


More information about the XOM-interest mailing list