From: Steve B. <Ste...@zv...> - 2004-11-24 20:41:25
|
Firstly, in your script you reused the "div" variable, thus creating two <div> elements but the variable refers to the second instance when the text is added. That's why the first <div> is an empty element. Secondly, the use of empty element syntax when the method is set to "html" is a bug; please submit a bug report on SourceForge. Cheers, Steve Ball On 24/11/2004, at 11:14 PM, Detlef Groth wrote: > > Hello, > > for a web application I build a dom-tree in memory and depending on > user input I hide or display certain parts of the dom-tree. > > Sample session to create the document: > (tclkit) 2 % package require xml::tcl > 3.0 > (tclkit) 3 % set doc [dom::DOMImplementation create] > invalid command name "dom::DOMImplementation" > (tclkit) 4 % package require dom > 3.0 > (tclkit) 5 % set doc [dom::DOMImplementation create] > ::dom::tcl::document1::Document > (tclkit) 6 % set top [dom::document createElement $doc html] > ::dom::tcl::document1::node2 > (tclkit) 7 % set head [dom::document createElement $top head] > ::dom::tcl::document1::node6 > (tclkit) 8 % set title [dom::document createElement $head title] > ::dom::tcl::document1::node10 > (tclkit) 9 % set titleText [dom::document createTextNode $title > "MPIMG Berlin - Mouse Database"] > ::dom::tcl::document1::node14 > (tclkit) 10 % set body [dom::document createElement $top body] > ::dom::tcl::document1::node18 > (tclkit) 11 % set div [dom::document createElement $body div] > ::dom::tcl::document1::node22 > (tclkit) 12 % dom::element setAttribute $div style display:none; > display:none > (tclkit) 13 % set div [dom::document createElement $body div] > ::dom::tcl::document1::node27 > (tclkit) 14 % [dom::document createTextNode $div Test] > wrong # args: should be "::dom::tcl::document1::node31 method args" > (tclkit) 15 % dom::document createTextNode $div Test > ::dom::tcl::document1::node35 > (tclkit) 16 % $doc serialize -html > unknown method "serialize" > (tclkit) 17 % dom::serialize $doc -method "html" > <?xml version='1.0'?> > <!DOCTYPE html> > <html><head><title>MPIMG Berlin - Mouse > Database</title></head><body><div > style="display:none"/><div>TestTest</div></body></html> > (tclkit) 18 % dom::serialize $doc -method "html" -indent > list must have an even number of elements > (tclkit) 19 % dom::serialize $doc -method "html" -indent 2 > <?xml version='1.0'?> > <!DOCTYPE html> > > <html> > <head> > <title>MPIMG Berlin - Mouse Database</title> > </head> > <body> > <div style="display:none"/> > <div>TestTest</div> > </body> > </html> > > > > both outputs did not render the text although the TestTest-text is not > a parent of the display:none-div. > > if we change the html-code manually to > > <html> > <head> > <title>MPIMG Berlin - Mouse Database</title> > </head> > <body> > <div style="display:none"></div> > <div>TestTest</div> > </body> > </html> > > which should be the same than it renders right. So my adivise is to > change the following: > $ diff /d/tcl-lib/tcldom3.0/dom.tcl > ~/cvs/tclhttpd/customlib/tcldom3.0/dom.tcl > ... some other stuff > > < > < append result />$newline > --- >> # dgroth fixes bad browser behaviour with <div >> style='display:none'/> tags >> append result "></$nsPrefix$node(node:localName)>$newline" > > Or at least allow a option with serialize like: > > ::dom::DOMImplementation serialize $doc -emptytags false > > I think with tdom this is the default because I did not observe this > missbehaviour (of modern browsers) until now. > > regards, > Detlef > > -- > Dr. Detlef Groth > Max-Planck-Institut > fuer Molekulare Genetik > Ihnestr. 63/73 > D-14195 Berlin > Tel.: + 49 30 - 8413 1235 > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > 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 |