The DOMSerializer is DOM Level 1, namespace support requires DOM Level
2. We need to figure out a way to support both in the same serializer,
or only support DOM Level 2, which might break some existing
implementations.
For SAX, 1 and 2 use different interfaces so this was never a problem.
arkin
Anthony Dodd wrote:
>
> Hi
>
> I'm currently developing a web based application which needs to be able to
> transmit the contents of an XML Document (Built using Xerces 3.0.1) via HTTP
> to web application server. The document I want to send should have the
> following structure.
>
> <soap:Envelope xmlns:soap="Some-Namespace-URI">
> <soap:Body>
> <t:get xmlns:t="Someother-Namespace-URI">
> <t:element1/>
> </t:get>
> </soap:body>
> </soap:Envelope>
>
> I've attempted to create this document using the following java code. I'm
> making no assumptions that the following code is correct, so any guidelines
> would be really useful.
>
> //Create a new document with given Namespace & Qualified
> name
> org.w3c.dom.Document doc =
> dom.createDocument("Some-Namespace-URI","soap:Envelope",null);
>
> //Create the Body element
> org.w3c.dom.Element body =
> doc.createElementNS("Some-Namespace-URI", "soap:Body");
> doc.getDocumentElement().appendChild(body);
>
> //Create the get element
> org.w3c.dom.Element tget =
> doc.createElementNS("Someother-Namespace-URI", "t:get");
> body.appendChild(tget);
>
> //Create the element1 element
> org.w3c.dom.Element element1 =
> doc.createElementNS("Someother-Namespace-URI", "t:element1);
> tget.appendChild(element1);
>
> When I use the Xerces serializer via the XMLSerializer implementation, the
> following code snippet shows how I created and invoked the serializer.
>
> XMLSerializer serializer = new XMLSerializer(System.out, new
> OutputFormat(doc2));
> serializer.serialize(doc2);
> serializer.flush();
>
> this produces the following output
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <soap:Envelope><soap:Body><t:get><t:element1/></t:get></soap:Body></soap:Env
> elope>
>
> which does not exactly resemble the original document. Is the Xerces
> serializer compliant with DOM Level 2, can it recognise the namespaces and
> reproduce them in the serialized output. If any body got a solution to this
> problem I'd be most grateful.
>
> Thanks
> Anthony Dodd
--
----------------------------------------------------------------------
Assaf Arkin www.exoffice.com
CTO, Exoffice Technologies, Inc. www.exolab.org