Simon Kitching <[EMAIL PROTECTED]> wrote on 09/14/2004 05:41:22 PM:

> On Tue, 2004-09-14 at 19:47, Mucha, Dietrich RD-PN34 wrote:
> > Hi Neil,
> > 
> > thank you for that hint. An additional question:
> > As was pointed out by Michael Glavassevich one should switch from 
> XMLSerializer to the standard JAXP Transformation API.
> > He points to 
> >    http://marc.theaimsgroup.com/?l=xalan-dev&m=107593381313807&w=2
> > and using this hint my code for serializing a string looks like
> > 
> >             // Use a Transformer for output
> >             TransformerFactory tFactory = 
TransformerFactory.newInstance();
> >             Transformer transformer = tFactory.newTransformer();
> > 
> >             DOMSource source = new DOMSource(doc);
> >             StringWriter myOutByteStream = new StringWriter();
> >             StreamResult result = new StreamResult(myOutByteStream);
> >             transformer.transform(source, result); 
> > 
> >             strResult = myOutByteStream.toString();
> > 
> > But here I am back to field one, there is no output of the 
> namespace declarations.
> > 
> > Is there a solution for JAXP as well?
> > In transformer.setOutputProperty() I don't see something giving a 
> similar effect to 
> > 
> >    serializer.setNamespaces(true);
> >    serializer.serialize(doc);
> 
> Have you done this?
> 
>    // NS_MYMSG = "http://www.acme.com/namespaces/mymessage";;
>    // NS_XMLNS="http://www.w3.org/2000/xmlns/";;
>    Element foo = doc.createElementNS(NS_MYMSG, "msg:header");
>    foo.setAttributeNS(NS_XMLNS, "xmlns:msg", NS_MYMSG);
> 
> I *believe* that the new DOM3 stuff has a "normalize" method which will
> figure out where xmlns:... declarations should be inserted into the doc,
> but DOM2 doesn't; you need to add the xmlns declarations manually in the
> appropriate places (well, at least I have found this necessary).

With DOM Level 3 you can also configure the serializer [1] to perform 
fixup of namespaces during serialization.

http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#LS-LSSerializer

> I hope this helps,
> 
> Simon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to