I'm afraid that turns out not to be correct, Elliotte.
The DOM does not require namespace declaration attributes to be present. They typically are produced when a parser builds the DOM,, but the DOM is designed to operate perfectly happily without them.In that case, it is the responsibility of the serializer to create them on output, or for the DOM to be "namespace normalized" before being passed to code which expects them.
See DOM Level 3 for details and suggested algorithms.
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
Elliotte Harold <[EMAIL PROTECTED]>
09/14/2004 07:19 AM
|
To: [EMAIL PROTECTED] cc: Subject: Re: Problem with serialization of a DOM with xerces 2.6.2 |
Mucha, Dietrich RD-PN34 wrote:
>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);
>
>
>
It's not your fault. You're hitting a major design flaw in DOM. DOM
requires you to both specify the namespaces for individual elements and
attributes in a namespace *and* to add Attr objects to elements
identifying the namespace declarations. Worse yet, there's nothing that
keeps these two sources of namespace information in sync. :-(
If your documents are reasonably simple namespace wise, try adding the
necessary xmlns and xmlns:prefix Attr objects to the document element.
If different namespaces are in scope in different places, then it's a
little trickier, but the solution is still to add Attr objects
representing the xmlns attributes to the correct elements.
--
Elliotte Rusty Harold
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]