From: Mats B. <ma...@pr...> - 2001-09-27 12:50:19
|
> > Mats Bengtsson wrote: > > > > The docs for TclXML specify the -errorcommand proc to take two parameters, > > 'tclProc errorcode errormessage', but browsing through the 'sgmlparser.tcl' > > file, the error proc is usually called as: > > > > uplevel #0 $options(-errorcommand) "$attr around line $state(line)" ... > > > > Am I right here? > > Hmmm... yes I'd say so. The Error procedure in sgml-8.[01].tcl simply > uses 'args'. Sorry about that! Would you care to submit a patch? ;-) > Since I don't know the code that well, the risk is that I create more errors than I fix. One related issue. If I make a crude workaround by having 'args' in the errorcommand proc, see below, the elementendcommand fails, see stack below. What is the correct procedure to make the best error recovery? /Mats code----------------------------------- set data2 {<stream:error>Invalid XML</stream:error>} . proc HandleErrorFix {args} { global myParser puts "HandleErrorFix ==> args=$args" $myParser reset $myParser free $myParser } set myParser [xml::parser] $myParser configure -elementstartcommand HandleStart \ -elementendcommand HandleEnd -characterdatacommand HandleText \ -final 0 -errorcommand HandleErrorFix $myParser parse $data2 backtrace*************************************** can't read "namespaces()": no such variable while executing "set nsuri $namespaces([lindex [lsort -dictionary -decreasing [array names namespaces $prefix,*]] 0])" (procedure "ParseEvent:ElementClose" line 17) invoked from within "ParseEvent:ElementClose $tag [array get options]" invoked from within "::sgml::parseEvent {stream:error {} {} {Invalid XML} stream:error / {} {}} -emptyelement {namespace inscope ::xml::tclparser ParseEmpty} -parseattribu..." ("eval" body line 1) invoked from within "eval ::sgml::parseEvent [list $tokenised] $parseOptions" (procedure "parse" line 38) invoked from within "parse xmlparser1 {<stream:error>Invalid XML</stream:error>}" (in namespace inscope "::xml::tclparser" script line 1) invoked from within "namespace inscope ::xml::tclparser parse xmlparser1 {<stream:error>Invalid XML</stream:error>}" ("eval" body line 1) invoked from within "eval $classinfo(-parsecommand) [list $name] $args" ("parse" arm line 5) invoked from within "switch -- $method { configure { # BUG: We're not checking for legal options array set data $args eval $classinfo(-configurecommand) [..." (procedure "::xml::ParserCmd" line 7) invoked from within "::xml::ParserCmd xmlparser1 parse {<stream:error>Invalid XML</stream:error>}" ("eval" body line 1) invoked from within "eval ::xml::ParserCmd xmlparser1 [list $method] $args" (procedure "xmlparser1" line 1) invoked from within "$myParser parse $data2" (file "" line 46) |