|
From: Steve B. <Ste...@ex...> - 2008-02-19 21:49:18
|
Hi BR,
If you are only parsing an XML document you do not need to define a
new parser class. In fact, you have created a parser class that
performs a no-op, so when you go to parse a document nothing will
happen. In almost every circumstance, you should use the package-
supplied parser class (either the pure-Tcl or libxml2 parser).
HTHs,
Steve Ball
On 18/02/2008, at 6:43 PM, 虞乐 wrote:
> Hi,
>
> I am trying on the version 3.0 of tclxml, and I found it does
> not work as I wish to. Though I am a beginner of using tclxml, there
> may be some misunderstanding of the user guide. The attachment is
> the script of mine test case, which did a invoking job of xml file
> reading. Pls inform me whether there's any defect of my code, and it
> will be so appreciated. Thanks.
>
> BR
>
> from a user of tclxml
>
> And the script as:
>
> package require xml::tcl 3.0
> namespace import xml::*
> proc CCreate { args } { }
> proc CConfig { args } { }
> proc CParse { args } { }
> proc CEntityParse { args } { }
> proc CGet { args } { }
> proc CDel { args } { }
> proc CAttlistdecl { args } {
> puts "CAttlistdecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CElementdecl { args } {
> puts "CElementdecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CCharacterdata { data args } {
> puts "CCharacterdata invoked..."
> puts -nonewline $data
> foreach arg $args {
> puts $arg
> }
> }
> proc CComment { args } {
> puts "CComment invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CDefault { args } {
> puts "CDefault invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CDoctype { args } {
> puts "CDoctype invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CElementend { args } {
> puts "CElementend invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CElementstart { args } {
> puts "CElementstart invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CEndcdatasection { args } {
> puts "CEndcdatasection invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CEnddoctypedecl { args } {
> puts "CEnddoctypedecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CEntitydecl { args } {
> puts "CEntitydecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CEntityreference { args } {
> puts "CEntityreference invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CError { args } {
> puts "CError invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CExternalentity { args } {
> puts "CExternalentity invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CNotationdecl { args } {
> puts "CNotationdecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CNotstandalone { args } {
> puts "CNotstandalone invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CParameterentitydecl { args } {
> puts "CParameterentitydecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CProcessinginstruction { args } {
> puts "CProcessinginstruction invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CStartcdatasection { args } {
> puts "CStartcdatasection invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CStartdoctypedecl { args } {
> puts "CStartdoctypedecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CUnknownencoding { args } {
> puts "CUnknownencoding invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CUnparsedentitydecl { args } {
> puts "CUnparsedentitydecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CWarning { args } {
> puts "CWarning invoked..."
> foreach arg $args {
> puts $arg
> }
> }
> proc CXmldecl { args } {
> puts "CXmldecl invoked..."
> foreach arg $args {
> puts $arg
> }
> }
>
> set filePath "C:/Tcl/lib/AgtBGP/test.xml"
> set IOhandle [ open $filePath r ]
> set xml [ read -nonewline $IOhandle ]
> close $IOhandle
> #puts $xml
> ::xml::parserclass create xmltest \
> -createcommand CCreate \
> -configurecommand CConfig \
> -parsecommand CParse \
> -createentityparsercommand CEntityParse \
> -getcommand CGet \
> -deletecommand CDel
> puts "parser class built success..."
> set parser [ ::xml::parser \
> -validate 1 \
> -parser xmltest \
> -attlistdeclcommand CAttlistdecl \
> -characterdatacommand CCharacterdata \
> -commentcommand CComment \
> -defaultcommand CDefault \
> -defaultexpandinternalentities 0 \
> -doctypecommand CDoctype \
> -elementdeclcommand CElementdecl \
> -elementendcommand CElementend \
> -elementstartcommand [ list CElementstart 1 2 3
> 4 5 ] \
> -endcdatasectioncommand CEndcdatasection \
> -enddoctypedeclcommand CEnddoctypedecl \
> -entitydeclcommand CEntitydecl \
> -entityreferencecommand CEntityreference \
> -errorcommand CError \
> -externalentitycommand CExternalentity \
> -final 1 \
> -ignorewhitespace 1 \
> -notationdeclcommand CNotationdecl \
> -notstandalonecommand CNotstandalone \
> -parameterentitydeclcommand CParameterentitydecl \
> -paramentityparsing 1 \
> -processinginstructioncommand
> CProcessinginstruction \
> -reportempty 1 \
> -startcdatasectioncommand CStartcdatasection \
> -startdoctypedeclcommand CStartdoctypedecl \
> -unknownencodingcommand CUnknownencoding \
> -unparsedentitydeclcommand CUnparsedentitydecl \
> -validate 1 \
> -warningcommand CWarning \
> -xmldeclcommand CXmldecl \
> ]
> #set parser [ ::xml::parser \
> # -characterdatacommand CCharacterdata \
> # ]
> puts "parser built success..."
> puts "XML: $xml"
> set result [ $parser parse $xml ]
> puts "parsing success..."
>
>
>
> 网 易 有 道 英 汉 电 子 词 典 获 2 0
> 0 7 年 “ 电 脑 报 ” 免 费 软 件 最
> 佳 功 能 奖
> <
> test
> .rar
> >
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
> Tclxml-users mailing list
> Tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tclxml-users
|