Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] naespace declaration lost

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: "Carsten Karkola" <carsten.karkola AT mailbox.tu-dresden.de>, xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] naespace declaration lost
  • Date: Sun, 19 Jan 2003 04:39:30 -0500

At 11:26 PM +0100 1/18/03, Carsten Karkola wrote:
Hello,

I tried to print the following document with
nu.xom.samples.XMLPrinter:

<?xml version="1.0" encoding="ISO-8859-1"?>
<test
xmlns="http://www.tu-dresden.de/bau/test";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.tu-dresden.de/bau/test test.xsd">
<a>
<b>test1</b>
</a>
</test>

and I get

<?xml version="1.0"?>
<test
xmlns="http://www.tu-dresden.de/bau/test";
xsi:schemaLocation="http://www.tu-dresden.de/bau/test test.xsd">
<a>
<b>test1</b>
</a>
</test>

I've verified this bug and fixed it in my local source. Thanks for reporting it. I hope to have a 1.0d9 up tomorrow that incorporates this and several other things that I've fixed or changed recently.

without the xmlns:xsi declaration. I think, the problem starts in
nu.xom.Serializer in line 239:
String currentURI =
element.getNamespaceURI(attribute.getNamespacePrefix());
// I think, this is always false, because the call to
// getNamespaceURI() finds the Attribute NS and so is
// attributeURI equal to the currentURI
if (!attributeURI.equals(currentURI)) {}


That is true, though the sample program you cite did not actually use the Serializer, just toXML, However, both shared the same bug and I've fixed both. They now actually share more code than they did before.

Interestingly, the CanonicalXMLSerializer class did not share this bug. It had more careful namespace handling.
--

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo AT metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| Processing XML with Java (Addison-Wesley, 2002) |
| http://www.cafeconleche.org/books/xmljava |
| http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+




Archive powered by MHonArc 2.6.24.

Top of Page