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). I hope this helps, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]