>But in that case, the serializer will have to be aware of the >hierarchy

Yep.

But since folks _can_ constuct entirely legitimate DOM trees with
namespaced nodes and without namespace declarations, the serializer really
doesn't have much choice about this, unless it wants to throw exceptions or
generate erroneous XML.

Handling it really doesn't complicate matters all that much; it requires
maintaining a stack of namespaces-currently-in-context, and reconciling the
occasional case where someone used the same prefix on both an element and
one of its attrs but bound those nodes to two different namespaces... but
it really is quite straightforward.

>The code that I currently have uses the NS API, but adds the
>'xmlns' attr anyway

That's often optimal, since it lets you say exactly where you want the
namespaces declared (which may be well before they're actually used). But
if you don't, a good DOM Level 2 serializer will Do The Right Thing to
produce an XML file which is "namespace-well-formed" and correctly
represents your intent.




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

Reply via email to