<manpage id="expat" cat="cmd" title="expat">
    <namesection>
      <name>expat</name>
      <desc>Creates an instance of an expat parser object</desc>
    </namesection>

<!--

 Copyright (c) 1999 Jochen Loewer (loewerj@hotmail.com)

 See the file "LICENSE" for information on usage and redistribution
 of this file, and for a DISCLAIMER OF ALL WARRANTIES.

-->

    <synopsis>
      <syntax>package require tdom

<cmd>expat</cmd> ?<m>parsername</m>? ?<m>-namespace</m>? ?<m>arg arg ..</m>

<cmd>xml::parser</cmd> ?<m>parsername</m>? ?<m>-namespace</m>? ?<m>arg arg ..</m></syntax>
    </synopsis>
    <section>
      <title>DESCRIPTION</title>

      <p>The parser created with <m>expat</m> or <m>xml::parser</m>
(which is just another name for the same command in an own namespace) are able
to parse any kind of well-formed XML. The parsers are stream oriented XML
parser. This means that you register handler scripts with the parser prior to
starting the parse. These handler scripts are called when the parser discovers
the associated structures in the document being parsed.  A start tag is an
example of the kind of structures for which you may register a handler
script.</p>

<p>The parsers always check for XML well-formedness of the input (and
report error, if the input isn't well-formed). They parse the internal
DTD and, at request, external DTD and external entities, if you
resolve the identifier of the external entities with the
-externalentitycommand script (see there). If you use the -validateCmd
option (see there), the input is additionally validated.</p>

<p>Additionly, the Tcl extension code that implements this command provides an
API for adding C level coded handlers. Up to now, there exists the parser
extension command "tdom". The handler set installed by this extension build an
in memory "tDOM" DOM tree, while the parser is parsing the input.</p>

<p>It is possible to register an arbitrary amount of different handler scripts
and C level handlers for most of the events. If the event occurs, they are
called in turn.</p>

    </section>

    <section>
      <title>COMMAND OPTIONS</title>

      <optlist>
        <optdef>
          <optname>-namespace</optname>

          <desc><p>Enables namespace parsing. You must use this option while
creating the parser with the <samp>expat</samp> or <samp>xml::parser</samp>
command. You can't enable (nor disable) namespace parsing with
<samp>&lt;parserobj&gt; configure ...</samp>.</p>
</desc>
        </optdef>

        <optdef>
          <optname>-namespaceseparator</optname>
          <optarg>char</optarg>

          <desc><p>This option has only effect, if used together with
          the option <m>-namespace</m>. If given, this option
          determines the character inserted between namespace URI and
          the local name, while reporting an XML element name to a
          handler script. The default is the character ':'. The
          value must be a one-character string less or equal to
          \u00FF, preferably a 7-bit ASCII character or the empty
          string. If the value is the empty string (as well, as if the
          value is \x00) the namespace URI and the local name will be
          concatenated without any separator.</p></desc>
        </optdef>
        
        <optdef>
          <optname>-final</optname>
          <optarg>boolean</optarg>

          <desc><p>This option indicates whether the document data next
presented to the parse method is the final part of the document. A value of "0"
indicates that more data is expected. A value of "1" indicates that no more is
expected.  The default value is "1".</p>

<p>If this option is set to "0" then the parser will not report certain errors
if the XML data is not well-formed upon end of input, such as unclosed or
unbalanced start or end tags. Instead some data may be saved by the parser
until the next call to the parse method, thus delaying the reporting of some of
the data.</p>

<p>If this option is set to "1" then documents which are not well-formed upon
end of input will generate an error.</p></desc>
        </optdef>

        <optdef>
          <optname>-validateCmd</optname>
          <optarg>&lt;tdom schema cmd&gt;</optarg>

          <desc><p>This option expects the name of a tDOM schema
          command. If this option is given, then the input is also
          validated. If the schema command hasn't set a reportcmd then
          the first validation error will stop further parsing (as a
          well-formedness error).</p></desc>
        </optdef>

        <optdef>
          <optname>-baseurl</optname>
          <optarg>url</optarg>

          <desc><p>Reports the base url of the document to the
parser.</p></desc>
        </optdef>

        <optdef>
          <optname>-fastcall</optname>
          <optarg>boolean</optarg>

          <desc><p>By default this option is 0 (off). If this option
          is on then any handler installed by the options
          <m>-elementstartcommand</m>, <m>-elementendcommand</m> and
          <m>-characterdatacommand</m> from this moment on is
          installed in a way that calling it has lesser overhead as
          usual. This option may be switched between callback hander
          (re-)installion as desired.</p>

          <p>However this has some requirenments. The handler proc has
          to be defined before used as callback. If it is not then
          the callback is installed as ususal. And the handler proc
          must not be removed or re-defined as long as it is used as
          callback. If this is done the programm probably will crash
          but also may execute arbitrary code.</p>

          <p>The callback handler installed while this option is on
          will not be traced by executing them. </p></desc>
        </optdef>

        <optdef>
          <optname>-keepTextStart</optname>
          <optarg>boolean</optarg>

          <desc><p>By default this option is 0 (off). If this option
          is on then the position information of the start of a text
          or CDATA node is keeped over collecting the sometimes by
          expat delivered cdata pieces. With this option on the
          position information returned by the parser in a
          -characterdatacommand proc will be correct, otherwise not.
          Called in all other handler code the parser always return
          the correct position results, no matter what value this
          option have. It is off by default because it is rarely
          needed and saves a few cpu cyles this way.</p></desc>
        </optdef>
        
        <optdef>
          <optname>-elementstartcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the start tag of
an element. The actual command consists of this option followed by at least two
arguments: the element type name and the attribute list.</p>

<p>The attribute list is a Tcl list consisting of name/value pairs, suitable
for passing to the array set Tcl command.</p>

<p>Example:</p>
<example>proc HandleStart {name attlist} {
    puts stderr "Element start ==> $name has attributes $attlist"
}

$parser configure -elementstartcommand HandleStart

$parser parse {&lt;test id="123"&gt;&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>
<example>HandleStart text {id 123}</example>
</desc>
        </optdef>

        <optdef>
          <optname>-elementendcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the end tag of an
element. The actual command consists of this option followed by at least one
argument: the element type name. In addition, if the -reportempty option is set
then the command may be invoked with the -empty configuration option to
indicate whether it is an empty element. See the description of the
-reportempty option for an example. </p>

<p>Example: </p>
<example>proc HandleEnd {name} {
    puts stderr "Element end ==> $name"
}

$parser configure -elementendcommand HandleEnd

$parser parse {&lt;test id="123"&gt;&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>
<example>
HandleEnd test
</example>
</desc>
        </optdef>


        <optdef>
          <optname>-characterdatacommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with character data in
the document, ie. text. The actual command consists of this option followed by
one argument: the text.</p>

<p>Other than with the C API of the expat parser it is guaranteed that
character data will be passed to the application in a single call to
this command.</p>

<p>Example: </p>

<example>proc HandleText {data} {
    puts stderr &quot;Character data ==&gt; $data&quot;
}

$parser configure -characterdatacommand HandleText

$parser parse {&lt;test&gt;this is a test document&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>

<example>HandleText {this is a test document}</example>
</desc>
        </optdef>


        <optdef>
          <optname>-processinginstructioncommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with processing
instructions in the document. The actual command consists of this option
followed by two arguments: the PI target and the PI data.</p>

<p>Example: </p>

<example>proc HandlePI {target data} {
    puts stderr &quot;Processing instruction ==&gt; $target $data&quot;
}

$parser configure -processinginstructioncommand HandlePI

$parser parse {&lt;test&gt;&lt;?special this is a processing instruction?&gt;&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked: </p>

<example>
HandlePI special {this is a processing instruction}
</example>
            </desc>
        </optdef>

        <optdef>
          <optname> -notationdeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with notation
declaration in the document. The actual command consists of this option
followed by four arguments: the notation name, the base uri of the document
(this means, whatever was set by the -baseurl option), the system identifier
and the public identifier. The notation name is never empty, the other
arguments may be.</p></desc>
        </optdef>

        <optdef>
          <optname> -externalentitycommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with references to
external entities in the document. The actual command consists of this option
followed by three arguments: the base uri, the system identifier of the entity
and the public identifier of the entity. The base uri and the public identifier
may be the empty list.</p>

<p>This handler script has to return a tcl list consisting of three
elements. The first element of this list signals, how the external entity is
returned to the processor. At the moment, the three allowed types are
&quot;string&quot;, &quot;channel&quot; and &quot;filename&quot;. The second
element of the list has to be the (absolute) base URI of the external entity to
be parsed.  The third element of the list are data, either the already read
data out of the external entity as string in the case of type
&quot;string&quot;, or the name of a tcl channel, in the case of type
&quot;channel&quot;, or the path to the external entity to be read in case of
type &quot;filename&quot;. Behind the scene, the external entity referenced by
the returned Tcl channel, string or file name will be parsed with an expat
external entity parser with the same handler sets as the main parser. If
parsing of the external entity fails, the whole parsing is stopped with an
error message. If a Tcl command registered as externalentitycommand isn't able
to resolve an external entity it is allowed to return TCL_CONTINUE. In this
case, the wrapper give the next registered externalentitycommand a try. If no
externalentitycommand is able to handle the external entity parsing stops with
an error.</p>

<p>Example:</p>

<example>proc externalEntityRefHandler {base systemId publicId} {
    if {![regexp {^[a-zA-Z]+:/} $systemId]}  {
        regsub {^[a-zA-Z]+:} $base {} base
        set basedir [file dirname $base]
        set systemId &quot;[set basedir]/[set systemId]&quot;
    } else {
        regsub {^[a-zA-Z]+:} $systemId systemId
    }
    if {[catch {set fd [open $systemId]}]} {
        return -code error \
                -errorinfo &quot;Failed to open external entity $systemId&quot;
    }
    return [list channel $systemId $fd]
}

set parser [expat -externalentitycommand externalEntityRefHandler \
                  -baseurl &quot;file:///local/doc/doc.xml&quot; \
                  -paramentityparsing notstandalone]
$parser parse {&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE test SYSTEM &quot;test.dtd&quot;&gt;
&lt;test/&gt;}
</example>

<p>This would result in the following command being invoked:</p>

<example>
externalEntityRefHandler file:///local/doc/doc.xml test.dtd {}
</example>

<p>External entities are only tried to resolve via this handler script, if
necessary. This means, external parameter entities triggers this handler only,
if -paramentityparsing is used with argument &quot;always&quot; or if
-paramentityparsing is used with argument &quot;notstandalone&quot; and the
document isn't marked as standalone.</p>
            </desc>
        </optdef>
        
        <optdef>
          <optname> -unknownencodingcommand</optname>
          <optarg>script</optarg>

          <desc><p>Not implemented at Tcl level.</p></desc>
        </optdef>

        <optdef>
          <optname>-startnamespacedeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with start scope of
namespace declarations in the document. The actual command consists of this
option followed by two arguments: the namespace prefix and the namespace
URI. For an xmlns attribute, prefix will be the empty list.  For an
xmlns=&quot;&quot; attribute, uri will be the empty list. The call to the start
and end element handlers occur between the calls to the start and end namespace
declaration handlers.</p></desc>
        </optdef>

        <optdef>
          <optname> -endnamespacedeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with end scope of
namespace declarations in the document. The actual command consists of this
option followed by the namespace prefix as argument. In case of an xmlns
attribute, prefix will be the empty list. The call to the start and end element
handlers occur between the calls to the start and end namespace declaration
handlers.</p></desc>
        </optdef>

        <optdef>
          <optname> -commentcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with comments in the
document. The actual command consists of this option followed by one argument:
the comment data.</p>

<p>Example:</p>

<example>
proc HandleComment {data} {
    puts stderr &quot;Comment ==&gt; $data&quot;
}

$parser configure -commentcommand HandleComment

$parser parse {&lt;test&gt;&lt;!-- this is &lt;obviously&gt; a comment --&gt;&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>

<example>
HandleComment { this is &lt;obviously&gt; a comment }
</example>
            </desc>
        </optdef>
        
        <optdef>
          <optname> -notstandalonecommand</optname>
          <optarg>script</optarg>

          <desc><p>This Tcl command is called, if the document is not
standalone (it has an external subset or a reference to a parameter entity, but
does not have standalone=&quot;yes&quot;). It is called with no additional
arguments.</p></desc>
        </optdef>

        <optdef>
          <optname> -startcdatasectioncommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the start of a
CDATA section.  It is called with no additional arguments.</p></desc>
        </optdef>

        <optdef>
          <optname> -endcdatasectioncommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the end of a CDATA
section.  It is called with no additional arguments.</p></desc>
        </optdef>

        <optdef>
          <optname> -elementdeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with element
declarations. The actual command consists of this option followed by two
arguments: the name of the element and the content model. The content model arg
is a tcl list of four elements. The first list element specifies the type of
the XML element; the six different possible types are reported as
&quot;MIXED&quot;, &quot;NAME&quot;, &quot;EMPTY&quot;, &quot;CHOICE&quot;,
&quot;SEQ&quot; or &quot;ANY&quot;. The second list element reports the
quantifier to the content model in XML Syntax (&quot;?&quot;, &quot;*&quot; or
&quot;+&quot;) or is the empty list. If the type is &quot;MIXED&quot;, then the
quantifier will be &quot;{}&quot;, indicating an PCDATA only element, or
&quot;*&quot;, with the allowed elements to intermix with PCDATA as tcl list as
the fourth argument. If the type is &quot;NAME&quot;, the name is the third
arg; otherwise the third argument is the empty list. If the type is
&quot;CHOICE&quot; or &quot;SEQ&quot; the fourth argument will contain a list
of content models build like this one. The &quot;EMPTY&quot;, &quot;ANY&quot;,
and &quot;MIXED&quot; types will only occur at top level.</p>

<p>Examples:</p>

<example>
proc elDeclHandler {name content} {
     puts &quot;$name $content&quot;
}

set parser [expat -elementdeclcommand elDeclHandler]
$parser parse {&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE test [
&lt;!ELEMENT test (#PCDATA)&gt; 
]&gt;
&lt;test&gt;foo&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>

<example>
test {MIXED {} {} {}}

$parser reset
$parser parse {&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE test [
&lt;!ELEMENT test (a|b)&gt;
]&gt;
&lt;test&gt;&lt;a/&gt;&lt;/test&gt;}
</example>

<p>This would result in the following command being invoked:</p>

<example>
elDeclHandler test {CHOICE {} {} {{NAME {} a {}} {NAME {} b {}}}}
</example></desc>
        </optdef>


        <optdef>
          <optname> -attlistdeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with attlist
declarations. The actual command consists of this option followed by five
arguments.  The Attlist declaration handler is called for *each* attribute. So
a single Attlist declaration with multiple attributes declared will generate
multiple calls to this handler. The arguments are the element name this
attribute belongs to, the name of the attribute, the type of the attribute, the
default value (may be the empty list) and a required flag. If this flag is true
and the default value is not the empty list, then this is a &quot;#FIXED&quot;
default.</p>

<p>Example:</p>

<example>
proc attlistHandler {elname name type default isRequired} {
    puts &quot;$elname $name $type $default $isRequired&quot;
}

set parser [expat -attlistdeclcommand attlistHandler]
$parser parse {&lt;?xml version='1.0'?&gt;
&lt;!DOCTYPE test [
&lt;!ELEMENT test EMPTY&gt;
&lt;!ATTLIST test
          id      ID      #REQUIRED
          name    CDATA   #IMPLIED&gt;
]&gt;
&lt;test/&gt;}
</example>

<p>This would result in the following commands being invoked:</p>

<example>
attlistHandler test id ID {} 1
attlistHandler test name CDATA {} 0
</example></desc>
        </optdef>

        <optdef>
          <optname> -startdoctypedeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the start of the
DOCTYPE declaration. This command is called before any DTD or internal subset
is parsed.  The actual command consists of this option followed by four
arguments: the doctype name, the system identifier, the public identifier and a
boolean, that shows if the DOCTYPE has an internal subset.</p></desc>
        </optdef>

        <optdef>
          <optname> -enddoctypedeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with the end of the
DOCTYPE declaration. This command is called after processing any external
subset.  It is called with no additional arguments.</p></desc>
        </optdef>

        <optdef>
          <optname> -paramentityparsing</optname>
          <optarg>never|notstandalone|always</optarg>

          <desc><p>&quot;never&quot; disables expansion of parameter entities,
&quot;always&quot; expands always and &quot;notstandalone&quot; only, if the
document isn't &quot;standalone='no'&quot;. The default ist &quot;never&quot;</p></desc>
        </optdef>
        
        <optdef>
          <optname> -entitydeclcommand</optname>
          <optarg>script</optarg>

          <desc><p>Specifies a Tcl command to associate with any entity
declaration. The actual command consists of this option followed by seven
arguments: the entity name, a boolean identifying parameter entities, the value
of the entity, the base uri, the system identifier, the public identifier and
the notation name. According to the type of entity declaration some of this
arguments may be the empty list.</p></desc>
        </optdef>


        <optdef>
          <optname> -ignorewhitecdata</optname>
          <optarg>boolean</optarg>

          <desc><p>If this flag is set, element content which contain only
whitespaces isn't reported with the
<samp>-characterdatacommand</samp>.</p></desc>
        </optdef>

        <optdef>
          <optname> -ignorewhitespace</optname>
          <optarg>boolean</optarg>

          <desc>Another name for <m> -ignorewhitecdata</m>; see there.
            </desc>
        </optdef>

        <optdef>
          <optname> -handlerset</optname>
          <optarg>name</optarg>

          <desc><p>This option sets the Tcl handler set scope for the
configure options. Any option value pair following this option in the
same call to the parser are modifying the named Tcl handler set. If
you don't use this option, you are modifying the default Tcl handler
set, named &quot;default&quot;.</p></desc>
        </optdef>

        <optdef>
          <optname> -noexpand</optname>
          <optarg>boolean</optarg>

          <desc><p>Normally, the parser will try to expand references to
entities defined in the internal subset. If this option is set to a true value
this entities are not expanded, but reported literal via the default
handler. <b>Warning:</b> If you set this option to true and doesn't install a
default handler (with the -defaultcommand option) for every handler set of the
parser all internal entities are silent lost for the handler sets without a
default handler.</p>
            </desc>
        </optdef>

        <optdef>
          <optname>-useForeignDTD</optname>
          <optarg>&lt;boolean&gt;</optarg>
          <desc>If &lt;boolean&gt; is true and the document does not have an
external subset, the parser will call the -externalentitycommand script with
empty values for the systemId and publicID arguments. This option must be set,
before the first piece of data is parsed. Setting this option, after the
parsing has started has no effect. The default is not to use a foreign DTD. The
default is restored, after resetting the parser. Pleace notice, that a
-paramentityparsing value of "never" (which is the default) suppresses any call
to the -externalentitycommand script. Pleace notice, that, if the document also
doesn't have an internal subset, the -startdoctypedeclcommand and
enddoctypedeclcommand scripts, if set, are not called.</desc>
        </optdef>

        <optdef>
            <optname>-billionLaughsAttackProtectionMaximumAmplification</optname>
            <optarg>&lt;float&gt;</optarg>
            <desc>This option together with
            <m>-billionLaughsAttackProtectionActivationThreshold</m>
            gives control over the parser limits that protects
            against billion laugh attacks
            (<url>https://en.wikipedia.org/wiki/Billion_laughs_attack</url>).
            This option expects a float >= 1.0 as argument. You
            should never need to use this option, because the
            default value (100.0) should work for any real data.
            If you ever need to increase this value for non-attack
            payload, please report.</desc>
        </optdef>
    
        <optdef>
            <optname>-billionLaughsAttackProtectionActivationThreshold</optname>
            <optarg>&lt;long&gt;</optarg>
            <desc>This option together with
            <m>-billionLaughsAttackProtectionMaximumAmplification</m>
            gives control over the parser limits that protects
            against billion laugh attacks
            (<url>https://en.wikipedia.org/wiki/Billion_laughs_attack</url>).
            This option expects a positiv integer as argument. You
            should never need to use this option, because the
            default value (8388608) should work for any real data.
            If you ever need to increase this value for non-attack
            payload, please report.</desc>
        </optdef>

      </optlist>
    </section>
    <section>
      <title> COMMAND METHODS </title>

      <commandlist>
        <commanddef>
          <command><cmd>parser</cmd> <method>configure</method> <m>option value ?option value?</m></command>

          <desc><p>Sets configuration options for the parser. Every command
option, except <m>-namespace</m> can be set or modified with this method.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>cget</method> <m>?-handlerset name? option</m></command>

          <desc><p>Return the current configuration value option for the
parser.</p> 
          <p>If the -handlerset option is used, the configuration for the
named handler set is returned.</p>
          </desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>currentmarkup</method></command>

          <desc><p>Returns the current markup as found in the XML, if
          called from within one of its markup event handler script
          (-elementstartcommand, -elementendcommand, -commentcommand
          and -processinginstructioncommand). Otherwise it return the
          empty string.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>delete</method></command>

          <desc><p>Deletes the parser and the parser command. A parser cannot
be deleted from within one of its handler callbacks (neither directly nor
indirectly) and will raise a tcl error in this case.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>free</method></command>

          <desc><p>Another name to call the method <m>delete</m>, see
          there.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>get</method> <m>-specifiedattributecount|-idattributeindex|-currentbytecount|-currentlinenumber|-currentcolumnnumber|-currentbyteindex</m></command>
          <desc>
<optlist>
              <optdef>
                <optname>-specifiedattributecount</optname>

                <desc><p> Returns the number of the attribute/value pairs
passed in last call to the elementstartcommand that were specified in the
start-tag rather than defaulted. Each attribute/value pair counts as 2; thus
this corresponds to an index into the attribute list passed to the
elementstartcommand.</p></desc>
              </optdef>

              <optdef>
                <optname>-idattributeindex</optname>
                
                <desc><p>Returns the index of the ID attribute passed in the
last call to XML_StartElementHandler, or -1 if there is no ID attribute.  Each
attribute/value pair counts as 2; thus this corresponds to an index into the
attributes list passed to the elementstartcommand.</p></desc>
              </optdef>
              
              <optdef>
                <optname>-currentbytecount</optname>

                <desc><p>Return the number of bytes in the current event.
                Returns 0 if the event is in an internal entity.</p>

                <p>If you use this option consider if you may need the
                parser option <m>-keepTextStart</m>.</p>
                </desc>
              </optdef>

              <optdef>
                <optname>-currentlinenumber</optname>

                <desc><p> Returns the line number of the current parse
                location.</p>

                <p>If you use this option consider if you may need the
                parser option <m>-keepTextStart</m>.</p>
                </desc>
              </optdef>

              <optdef>
                <optname>-currentcolumnnumber</optname>

                <desc><p> Returns the column number of the current
                parse location.</p>

                <p>If you use this option consider if you may need the
                parser option <m>-keepTextStart</m>.</p>
                </desc>
              </optdef>

              <optdef>
                <optname>-currentbyteindex</optname>

                <desc><p> Returns the byte index of the current parse
                location.</p>

                <p>If you use this option consider if you may need the
                parser option <m>-keepTextStart</m>.</p>
                </desc>
              </optdef>
            </optlist>
<p>Only one value may be requested at a time.</p>
</desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>parse</method> <m>data</m></command>

          <desc><p>Parses the XML string <m>data</m>. The event callback
scripts will be called, as there triggering events happens. This method cannot
be used from within a callback (neither directly nor indirectly) of
the parser to be used and will raise an error in this case.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>parsechannel</method> <m>channelID</m></command>
          <desc><p>Reads the XML data out of the tcl channel <m>channelID</m>
(starting at the current access position, without any seek) up to the end of
file condition and parses that data. The channel encoding is respected. Use the
helper proc tDOM::xmlOpenFile out of the tDOM script library to open a file, if
you want to use this method. This method cannot
be used from within a callback (neither directly nor indirectly) of
the parser to be used and will raise an error in this case.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>parsefile</method> <m>filename</m></command>

          <desc><p>Reads the XML data directly out of the file with the
filename <m>filename</m> and parses that data. This is done with low-level file
operations. The XML data must be in US-ASCII, ISO-8859-1, UTF-8 or UTF-16
encoding. If applicable, this is the fastest way, to parse XML data. This
method cannot be used from within a callback (neither directly nor indirectly)
of the parser to be used and will raise an error in this case.</p></desc>
        </commanddef>

        <commanddef>
          <command><cmd>parser</cmd> <method>reset</method></command>

          <desc><p>Resets the parser in preparation for parsing another
document. A parser cannot be reset from within one of its handler callbacks
(neither directly nor indirectly) and will raise a tcl error in this
cases.</p></desc>
        </commanddef>
      </commandlist>
    </section>

    <section>
      <title>Callback Command Return Codes</title> 

      <p>A script invoked for any of the parser callback commands, such as
-elementstartcommand, -elementendcommand, etc, may return an error code other
than &quot;ok&quot; or &quot;error&quot;. All callbacks may in addition return
&quot;break&quot; or &quot;continue&quot;.</p>

      <p>If a callback script returns an &quot;error&quot; error code then
processing of the document is terminated and the error is propagated in the
usual fashion.</p>

      <p>If a callback script returns a &quot;break&quot; error code then all
further processing of every handler script out of this Tcl handler set is
suppressed for the further parsing. This does not influence any other handler
set.</p>

      <p>If a callback script returns a &quot;continue&quot; error code then
processing of the current element, and its children, ceases for every handler
script out of this Tcl handler set and processing continues with the next
(sibling) element. This does not influence any other handler set.</p>

      <p>If a callback script returns a &quot;return&quot; error
code then parsing is canceled altogether, but no error is raised.</p>

    </section>

    <seealso>
      <ref>expatapi</ref>
      <ref>tdom</ref>
    </seealso>

    <keywords>
      <keyword>SAX</keyword>
      <keyword>push</keyword>
      <keyword>pushparser</keyword>
    </keywords>
  </manpage>



  
