From: Steve M. <st...@re...> - 2004-01-05 00:59:45
|
I am seeing behavior which I do not expect but I'm not positive its a bug. If I serialize an XML document with a default namespace (e.g. xmlns="some-uri"), I get an null namespace in the output elements (e.g. <:tag> instead of <tag>). For example, I parse the following XML using dom::parse <rootnode xmlns="http://myuri"> <tag>value</tag> </rootnode> Then I serialize the dom with dom::serialize, I get the following: <?xml version='1.0'?> <!DOCTYPE :rootnode> <:rootnode xmlns:="http://myuri"> <:tag1>value</:tag1> </:rootnode> Note the semicolon before the element names. I did not expect this semicolon to be included. Am I defining my XML document incorrectly? It was my understanding that the default namespace (xmlns w/o any suffix) was the namespace for any element that did not have an explicit namespace attached. I would expect the output from the serialize function to be identical to the input in this case. I made a tweak to the dom library as follows which results in the behavior I desired: Change line 2851 in dom.tcl (tcldom 3.0b1) from: } elseif {[string length $node(node:namespaceURI)]} { to: } elseif {[string length $node(node:namespaceURI)] && \ [string length [GetNamespacePrefix $token $node(node:namespaceURI)]]} { * This does not fix the printing of the xmlns attribute in the root element and the DOCTYPE. but I'm not sure if this is the right thing to do. Essentially my goal was that if the xmlns prefix is null, then don't prepend. There might be a more appropriate place to handle this thought (if indeed I am using XML correctly). If needed, let me know and I'll log a bug. Thx, Steve |