From: Steve B. <Ste...@zv...> - 2004-01-05 20:47:44
|
Looks like a bug to me. I'll make sure the test suite has a test case for this situation. Given your previous post, I assume you're using 3.0b1? The pure-Tcl implementation? Cheers, Steve Ball On 05/01/2004, at 11:59, Steve McMillen wrote: > 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 > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for > IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys > admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Tclxml-users mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tclxml-users > Steve Ball | XSLT Standard Library | Training & Seminars Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development Ste...@zv... +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099 |