|
From: Simon W. <si...@pu...> - 2005-05-14 10:22:56
|
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
|