From: Steve B. <Ste...@ex...> - 2005-05-14 22:49:51
|
Dear Simon, This problem was reported as a bug on SF and has been fixed. The fix has not yet been committed to the CVS repository, but will be soon along with other changes for the v3.1 release (coming RSN). The problem was in the libxml2 wrapper code. This code now generates a call to the endelement callback for empty elements. However, due to the current TclXML C API it cannot signal the empty element (ie. -empty true) in the args. For the purpose of making the v3.1 release I won't change the C API, but will get that into a future v3.2 release. HTHs, Steve Ball On 14/05/2005, at 8:22 PM, Simon Wright wrote: > I'm a newcomer to the list, using TclTkAquaBI-8.4.9.0 (MacOS X), and I > seem to have the same problem. > > I'm not sure what David's script was intended to show since it doesn't > have the problematic structure! > > This script > --------------------------------- > package require xml > > proc elemStartCmd {elem_type attr_list args} { > puts [list >>>>>>>>>> open $elem_type ($attr_list $args)] > } > > proc elemEndCmd {elem_type args} { > puts [list >>>>>>>>>> close $elem_type ($args)] > } > > proc descriptiveData {cdata} { > puts [list cdata: $cdata] > } > > set theParser [::xml::parser \ > -elementendcommand elemEndCmd \ > -elementstartcommand elemStartCmd \ > -characterdatacommand descriptiveData \ > -reportempty 1 ] > > set xmldata "" > append xmldata "<toplevel> Document root\n" > append xmldata " <abstract></abstract>/n" > append xmldata " <abstract/>/n" > append xmldata "</toplevel>\n" > > $theParser parse $xmldata > --------------------------------- > outputs this > --------------------------------- > grendel:~/cf simon$ tclsh endcommand.tcl > >>>>>>>>>> open toplevel ( {-namespace {})} > cdata: { Document root > } > >>>>>>>>>> open abstract ( {-namespace {})} > >>>>>>>>>> close abstract () > cdata: {/n } > >>>>>>>>>> open abstract ( {-namespace {})} > cdata: /n > >>>>>>>>>> close toplevel () > --------------------------------- > so there are three things: > (a) the elementstartcommand doesn't see {-empty true} in args > (b) the elementendcommand doesn't see {-empty true} in args > (c) the elementendcommand doesn't get called at all for the empty > element. > > I didn't spot -reportempty at first, but it made no difference. > > Original message: > > Steve Ball <Steve.Ball@zv...> writes: > > > First I"ve heard of this... TclXML v3.0 is a major version change, > > but the API has not changed *that* much. > > > TclXML v3.X passes all of its regression tests. including the > > parsing API and parsing empty element syntax. I will investigate > > further, back a small sample XML source document and Tcl script > > would be helpful. > > Here"s a script that Massimo, the guy who noticed this, sent me. > > -- > David N. Welton > Personal: http://www.dedasys.com/davidw/ > Apache Tcl: http://tcl.apache.org/ > Free Software: http://www.dedasys.com/freesoftware/ > Linux Incompatibility List: http://www.leenooks.com/ > > ---- > package require xml > > proc elemStartCmd {elem_type attr_list args} { > puts [list >>>>>>>>>> open $elem_type ($attr_list $args)] > } > > proc elemEndCmd {elem_type args} { > puts [list >>>>>>>>>> close $elem_type ($args)] > } > > proc descriptiveData {cdata} { > puts [list cdata: $cdata] > } > > set theParser [::xml::parser \ > -elementendcommand elemEndCmd \ > -elementstartcommand elemStartCmd \ > -characterdatacommand descriptiveData ] > > set xmldata "" > append xmldata "<toplevel> Document root\n" > append xmldata " <livello1> Tag for generic element </livello1>\n" > append xmldata " <livello1 attr1_1=\"v1\" attr1_2=\"v2\"> Nuovo > Elemento contenente altri > Elementi\n" > append xmldata " <livello2 attr2_1=\"v1\" attr2_2=\"v2\"/>\n" > append xmldata " <livello2 attr2_1=\"v3\" attr2_2=\"v4\"/>\n" > append xmldata " <livello2> Tag chiuso in modo > \"canonico\" </livello2>\n" > append xmldata " </livello1>\n" > append xmldata "</toplevel>\n" > > $theParser parse $xmldata > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click > _______________________________________________ > Tclxml-users mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tclxml-users > > --- Steve Ball | XSLT Standard Library | Training & Seminars Explain | Web Tcl Complete | XML XSL Schemas http://www.explain.com.au/ | TclXML TclDOM | Tcl, Web Development Ste...@ex... +---------------------------+--------------------- Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099 |