tDOM

Artifact [3455a43a87]
Login

Artifact [3455a43a87]

Artifact 3455a43a87cedfe4dfef476f86fb2e9ba4bf96add28e9a47535f32f0f0a98ec9:


<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domDoc</title><meta name="xsl-processor" content="Jochen Loewer ([email protected]), Rolf Ade ([email protected]) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x1eae960">NAME</a> · <a href="#SECTid0x1e5ff20">SYNOPSIS</a> · <a href="#SECTid0x1e97f70">DESCRIPTION </a> · <a href="#SECTid0x1efaea0">SEE ALSO</a> · <a href="#SECTid0x1efb230">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x1eae960">NAME</a></h2><p class="namesection">
<b class="names">domDoc - </b><br>Manipulates an instance of a DOM document object</p>
  
  <h2><a name="SECTid0x1e5ff20">SYNOPSIS</a></h2><pre class="syntax">domDocObjCmd <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre><pre class="syntax">domDoc <i class="m">docToken</i> <i class="m">method</i> ?<i class="m">arg arg ...</i>?</pre>

  <h2><a name="SECTid0x1e97f70">DESCRIPTION </a></h2><p>This command manipulates one particular instance of a document
object. <i class="m">method</i> indicates a specific method of the document class. These
methods should closely conform to the W3C recommendation "Document Object Model
(Core) Level 1" (<a href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html">http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html</a>). Look
at these documents for a deeper understanding of the functionality.</p><p>The valid methods are:</p><dl class="commandlist">
        
          <dt>
<b class="method">documentElement</b> ?<i class="m">objVar</i>?</dt>
          <dd>Returns the top most element in the document (the root
element).</dd>
        

        
          <dt>
<b class="method">getElementsByTagName</b> <i class="m">name</i>
</dt>
          <dd>Returns a list of all elements in the document matching
(glob style) <i class="m">name</i>.</dd>
        

      
        <dt>
<b class="method">getElementsByTagNameNS</b> <i class="m">uri</i> <i class="m">localname</i>
</dt>
        <dd> Returns a list of all elements in the subtree
matching (glob style) <i class="m">localname</i> and having the given namespace
<i class="m">uri</i>.</dd>
      

        
          <dt>
<b class="method">createElement</b> <i class="m">tagName</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates (allocates) a new element node with node name
<i class="m">tagName</i>, append it to the hidden fragment list in the document
object and returns the node object.  If <i class="m">objVar</i> is given the new
node object is stored in this variable.</dd>
        

        
          <dt>
<b class="method">createElementNS</b> <i class="m">url</i> <i class="m">tagName</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates (allocates) a new element node within a namespace
having <i class="m">uri</i> as the URI and node name <i class="m">tagName</i>, which
could include the namespace prefix, append it to the hidden fragment list in
the document object and returns the node object.  If <i class="m">objVar</i> is
given the new node object is stored in this variable.</dd>
        

        
          <dt>
<b class="method">createTextNode</b> <i class="m">text</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates (allocates) a new text node with node value
<i class="m">text</i>, appends it to the hidden fragment list in the document
object and returns the node object.  If <i class="m">objVar</i> is given, the new
node object is stored in this variable.</dd>
        

        
          <dt>
<b class="method">createComment</b> <i class="m">text</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates (allocates) a new comment node with value
<i class="m">text</i>, appends it to the hidden fragment list in the document
object and returns the node object.  If <i class="m">objVar</i> is given, the new
comment node object is stored in this variable.</dd>
        

        
          <dt>
<b class="method">createCDATASection</b> <i class="m">data</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates (allocates) a new CDATA node with node value
<i class="m">data</i>, appends it to the hidden fragment list in the document
object and returns the node object.  If <i class="m">objVar</i> is given, the new
node object is stored in this variable.</dd>
        

        
          <dt>
<b class="method">createProcessingInstruction</b> <i class="m">target</i> <i class="m">data</i> ?<i class="m">objVar</i>?</dt>
          <dd>Creates a process instruction, appends it to the hidden
fragment list in the document object and returns the node object.  If
<i class="m">objVar</i> is given, the new node object is stored in this variable.</dd>
        

        
          <dt><b class="method">delete</b></dt>
          <dd>Explicitly deletes the document, including the associated
Tcl object commands (for nodes, fragment/new nodes, the document object itself)
and the underlying DOM tree.</dd>
        

        
          <dt><b class="method">getDefaultOutputMethod</b></dt>
          <dd>Returns the default output method of the document. This is
usually a result of a XSLT transformation.</dd>
        

      
        <dt>
<b class="method">asXML</b> <b class="option">?-indent none/1..8?</b> <b class="option">?-channel channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-doctypeDeclaration &lt;boolean&gt;?</b> <b class="option">-xmlDeclaration &lt;boolean&gt;?</b> <b class="option">-encString &lt;string&gt;</b> <b class="option">?-escapeAllQuot?</b> <b class="option">?-indentAttrs?</b> <b class="option">?-nogtescape?</b> <b class="option">?-noEmptyElementTag?</b>
</dt>
        <dd>
<p>Returns the DOM tree as an (optional indented) XML
        string or sends the output directly to the given
        channelId.</p>

        <p>If the option <i class="m">-escapeNonASCII</i> is given,
        every non 7 bit ASCII character in attribute values or element
        PCDATA content will be escaped as character reference in
        decimal representation.</p>

        <p>The flag <i class="m">-doctypeDeclaration</i> determines whether
        there will be a DOCTYPE declaration emitted before the first
        node of the document. The default is not to emit it. The
        DOCTYPE name will always be the element name of the document
        element. An external entity declaration of the external subset
        is only emitted if the document has a system identifier.</p>

        <p>The flag <i class="m">-xmlDeclaration</i> determines whether there
        will be an XML Declaration and a newline emitted before
        anything else. The default is not to emit one. If this flag is
        given with a true argument then</p>

        <p>
<i class="m">-encString</i> sets the encoding value in the XML
        Declaration. Otherwise this option is ignored. Please note
        that this option just enhances the string representation of the
        generated XML Declaration with an encoding information string,
        nothing more. It's up to the user to handle encoding in case
        of writing to a channel or reparsing.</p>
            
        <p>If the option <i class="m">-escapeAllQuot</i> is given,
        quotation marks will be escaped with &amp;quot; even in text
        content of elements.</p>

        <p>If the option <i class="m">-indentAttrs</i> is
        given, then attributes will each be separated with newlines
        and indented to the same level as the parent node plus the
        value given as argument to <i class="m">-indentAttrs</i> (0..8).</p>

        <p>If the option <i class="m">-nogtescape</i> is given then the
        character '&gt;' won't get escaped in attribute values and text
        content of elements. The default is to escape this
        character.</p>

        <p>If the option <i class="m">-noEmptyElementTag</i> is given then no
        empty tag syntax will be used. Instead, if an element has
        empty content it will be serialized with an element start tag
        and an immediately following element end tag.</p>
</dd>

      

      
        <dt>
<b class="method">asHTML</b> <b class="option">?-channel
channelId?</b> <b class="option">?-escapeNonASCII?</b> <b class="option">?-htmlEntities?</b> <b class="option">?-doctypeDeclaration &lt;boolean&gt;?</b>
</dt> 
        <dd>Returns the DOM tree serialized according to HTML rules
        (HTML elements are recognized regardless of case, without end
        tags for empty HTML elements etc.) as string or sends the
        output directly to the given channelId. If the option
        <i class="m">-escapeNonASCII</i> is given, every non 7 bit ASCII
        character in attribute values or element PCDATA content will
        be escaped as character reference in decimal representation.
        If the option <i class="m">-htmlEntities</i> is given, a character is
        written using its HTML 4.01 character entity reference, if it
        has one. If the flag <i class="m">-doctypeDeclaration</i> is given there
        will be a DOCTYPE declaration emitted before the first node of
        the document. The default is, to do not. The DOCTYPE name will
        always be the element name of the document element without
        case normalization. An external entity declaration of the
        external subset is only emitted, if the document has a system
        identifier. The doctype declaration will be written from the
        available information, without check, if this is a known
        (w3c) HTML version information or if the document confirms to
        the given HTML version.</dd>
      

      
        <dt><b class="method">asText</b></dt>
          <dd>The asText method returns the tree by serializing the
          string-value of every text node in document order without
          any escaping. In effect, this is what the xslt output method
          "text" (XSLT 1.0 recommendation, section 16.3) does.</dd>
      

      
        <dt>
<b class="method">asJSON</b> <b class="option">?-indent none/0..8?</b> <b class="option">?-channel channelId?</b>
</dt>
          <dd>
<p>The asJSON method serializes the tree into a valid
          JSON data string. In general, this may be a lossy
          serialization. For this serialization all comment, character
          data sections and processing instruction nodes, all
          attributes and all XML namespaces are ignored. Only element
          and text nodes may be reflected in the generated JSON
          serialization. Appropriate JSON data type information of a
          node will be respected.</p>

          <p>If an element node has the JSON type OBJECT, then every
          element node child of this element will be serialized as
          member of that object, with the node name of the child as
          the member name and the relevant children of that child as
          the value. Every other child nodes will be ignored.</p>

          <p>If an element node has the JSON type ARRAY, then the text
          and element node children of that element node are serialized
          as the consecutive values of the array. Element node children
          of an ARRAY element will be container nodes for nested ARRAY
          or OBJECT values.</p>

          <p>Text nodes with the JSON types TRUE, FALSE or NULL will
          be serialized to the corresponding JSON token without
          looking at the value of the text node. A text node without
          JSON type will always be serialized as a JSON string token.
          A text node with JSON type NUMBER will be serialized as JSON
          number token if the text node value is in fact a valid JSON
          number and as a JSON string if not.</p>

          <p>If an element node doesn't has a JSON type then the
          serialization of its children is determined by the following
          rules:</p>

          <p>Only text and element node child are relevant. If the
          element node to serialize is the member of a JSON object and
          there is no relevant child node the value of that member
          will be an empty JSON string. If the only relevant child
          node of this element node is a text node then the JSON
          value of that text node will be the value of the object
          member. If the element has more than one relevant child
          nodes and the first one is a text node then the relevant
          children will be serialized as JSON array. If the only
          relevant child node is an element node or the first relevant
          child is an element node and the node name of that only or
          first relevant child isn't equal to the array container node
          name all element node children will be serialized as the
          members of a JSON object (while ignoring any intermixed text
          nodes). If the only or first relevant child is an element
          node and the node name of this child is equal to the array
          container element name then all relevant children will be
          serialized as the values of a JSON array.</p>

          <p>If the element to serialize is a value of a JSON array
          and the node name of this element isn't equal to the array
          container node name that element will be seen as a container
          node for a JSON object and all element node children will be
          serialized as the members of that array while ignoring any
          text node children. If the element to serialize is a value of
          a JSON array and the node name of this element is equal to
          the array container node name, all relevant children will be
          serialized as JSON array.</p>

          <p>If the <i class="m">-channel</i> option is given the serialization
          isn't returned as string but send directly to the channel,
          given as argument to the option.</p>

          <p>If the <i class="m">-indent</i> option is given and the argument
          given to this option isn't "none" then the returned JSON
          string is "pretty-printed". The numeric argument to this
          option defines the number of spaces for any indentation
          level. The default is to not emit any additional
          white space.</p>
</dd>
      
      
      
        <dt>
<b class="method">publicId</b> <i class="m">?publicId?</i>
</dt>
        <dd>Returns the public identifier of the doctype declaration of the
document, if there is one, otherwise the empty string. If there is a value
given to the method, the public identifier of the document is set to this
value.</dd>
      

      
        <dt>
<b class="method">systemId</b> <i class="m">?systemId?</i>
</dt>
        <dd>Returns the system identifier of the doctype declaration of the
document, if there is one, otherwise the empty string. If there is a value
given to the method, the system identifier of the document is set to this
value.</dd>
      

      
        <dt>
<b class="method">internalSubset</b> <i class="m">?internalSubset?</i>
</dt>
        <dd>Returns the internal subset of the doctype declaration of the
document, if there is one, otherwise the empty string. If there is a value
given to the method, the internal subset of the document is set to this
value. Note that none of the parsing methods preserve the internal subset
of a document; a freshly parsed document will always have an empty internal
subset. Also note, that the method doesn't do any syntactical check on a
given internal subset.</dd>
      

      
        <dt>
<b class="method">cdataSectionElements</b> <i class="m">(?URI:?localname|*) ?&lt;boolean&gt;?</i>
</dt>
        <dd>This method allows one to control for which element nodes
the text node children will be serialized as CDATA sections (this affects only
serialization with the asXML method, no text node is altered in any
way by this method). IF the method is called with an element name as
first argument and a boolean with value true as second argument, every
text node child of every element node in the document with the same
name as the first argument will be serialized as CDATA section. If the
second argument is a boolean with value false, all text nodes of all
elements with the same name as the first argument will be serialized
as usual. Namespaced element names have to be given in the form
namespace_URI:localname, not in the otherwise usual prefix:localname
form. With two arguments called, the method returns the used boolean
value. If the method is called with only an element name, it will
return a boolean value, indicating that the text node children of all
elements with that name in the document will be serialized as CDATA
section elements (return value 1) or not (return value 0). If the
method is called with only one argument and that argument is an
asterisk ('*'), then the method returns an unordered list of all
element names of the document, for which the text node children will be
serialized as CDATA section nodes.</dd>
      

      
        <dt>
<b class="method">selectNodesNamespaces</b> <b class="option">?prefixUriList?</b>
</dt>
        <dd>This method allows one to control a document global prefix
        to namespace URI mapping, which will be used for selectNodes
        method calls (on document as well as on all nodes, which
        belongs to the document) if it is not overwritten by using
        the -namespaces option of the selectNodes method. Any
        namespace prefix within an xpath expression will be first
        resolved against this list. If the list binds the same prefix
        to different namespaces, then the first binding will win. If a
        prefix could not resolved against the document global prefix /
        namespaces list, then the namespace definitions in scope of
        the context node will be used to resolve the prefix, as usual.
        If the optional argument <i class="m">prefixUriList</i> is given, then
        the global prefix / namespace list is set to this list and
        returns it. Without the optional argument the method returns
        the current list. The default is the empty list.</dd>
      

      
        <dt>
<b class="method">xslt</b> <b class="option">?-parameters
parameterList?</b> <b class="option">?-ignoreUndeclaredParameters?</b>
<b class="option">?-maxApplyDepth int?</b>
<b class="option">?-xsltmessagecmd script?</b> <i class="m">stylesheet</i> <i class="m">?outputVar?</i>
</dt>
        <dd>Applies an XSLT transformation on the whole document of the node
object using the XSLT <i class="m">stylesheet</i> (given as domDoc). Returns a document
object containing the result document of the transformation and stores that
document object in the optional <i class="m">outputVar</i>, if that was given.

<p>The optional <i class="m">-parameters</i> option sets top level
&lt;xsl:param&gt; to string values. The <i class="m">parameterList</i> has to be a tcl
list consisting of parameter name and value pairs.</p>

<p>If the option <i class="m">-ignoreUndeclaredParameters</i> is given, then parameter
names in the <i class="m">parameterList</i> given to the <i class="m">-parameters</i> options that
are not declared as top-level parameters in the stylesheet are silently
ignored. Without this option, an error is raised if the user tries to set a
top-level parameter that is not declared in the stylesheet.</p>

<p>The option <i class="m">-maxApplyDepth</i> expects a positiv integer as
argument. By default, the xslt engine allows xslt templates to nest up
to 3000 levels (and raises error if they nest deeper). This limit can
be set by the <i class="m">-maxApplyDepth</i> option.</p>

<p>The <i class="m">-xsltmessagecmd</i> option sets a callback for xslt:message elements
in the stylesheet. The actual command consists of the script, given as argument
to the option, appended with the XML Fragment from instantiating the
xsl:message element content as string (as if the XPath string() function would
have been applied to the XML Fragment) and a flag, which indicates, if the
xsl:message has an attribute "terminate" with the value "yes". If the
called script returns anything else then TCL_OK then the xslt
transformation will be aborted, returning error. If the called script
returns -code break, the error message is empty, otherwise the result
code is reported. In case of terminated transformation, the outputVar,
if given, is set to the empty string.</p>
</dd>
      

      
        <dt>
<b class="method">toXSLTcmd</b> ?<i class="m">objVar</i>?</dt>
     
        <dd>If the DOM tree represents a valid XSLT stylesheet, this method
transforms the DOM tree into an xslt command, otherwise it returns error. The
created xsltCmd is returned and stored in the <i class="m">objVar</i>, if a var name was
given. A successful transformation of the DOM tree to an xsltCmd removes the
domDoc cmd and all nodeCmds of the document. 

<p>The syntax of the created xsltCmd is:</p>
 
<pre class="syntax">
<b class="cmd">xsltCmd</b> <b class="option">method</b> <b class="option">?arg ...?</b>
</pre>

<p>The valid methods are:</p>

<dl class="commandlist">
  
    <dt>
<b class="method">transform</b> <b class="option">?-parameters
parameterList?</b> <b class="option">?-ignoreUndeclaredParameters?</b>
<b class="option">?-maxApplyDepth int?</b> 
<b class="option">?-xsltmessagecmd script?</b> <i class="m">domDoc</i> <i class="m">?outputVar?</i>
</dt>          

        <dd>Applies XSLT transformation on the document
<i class="m">domDoc</i>. Returns a document object containing the
result document of that transformation and stores it in the optional
<i class="m">outputVar</i>. 

<p>The optional <i class="m">-parameters</i> option sets top level
&lt;xsl:param&gt; to string values. The <i class="m">parameterList</i> has to be a tcl
list consisting of parameter name and value pairs.</p>

<p>If the option <i class="m">-ignoreUndeclaredParameters</i> is given, then parameter
names in the <i class="m">parameterList</i> given to the <i class="m">-parameters</i> options that
are not declared as top-level parameters in the stylesheet are silently
ignored. Without this option, an error is raised if the user tries to set a
top-level parameter, which is not declared in the stylesheet.</p>

<p>The option <i class="m">-maxApplyDepth</i> expects a positiv integer as
argument. By default, the xslt engine allows xslt templates to nest up
to 3000 levels (and raises error if they nest deeper). This limit can
be set by the <i class="m">-maxApplyDepth</i> option.</p>

<p>The <i class="m">-xsltmessagecmd</i> option sets a callback for xslt:message elements
in the stylesheet. The actual command consists of the script, given as argument
to the option, appended with the XML Fragment from instantiating the
xsl:message element content as string (as if the XPath string() function would
have been applied to the XML Fragment) and a flag, which indicates, if the
xsl:message has an attribute "terminate" with the value "yes".</p>
</dd>
      

  
    <dt><b class="method">delete</b></dt>          
    <dd>Deletes the xsltCmd and cleans up all used recourses</dd>
  
</dl>

<p>If the first argument to an xsltCmd is a domDoc or starts with a "-",
then the command is processed in the same way as 
<i class="m">&lt;xsltCmd&gt; transform</i>.</p>
 </dd>
      

      
        <dt>
<b class="method">normalize</b> <i class="m">?-forXPath?</i>
</dt>
        <dd>Puts all text nodes in the document
into a "normal" form where only structure (e.g., elements,
comments, processing instructions and CDATA
sections) separates text nodes, i.e., there
are neither adjacent text nodes nor empty text nodes. If the option
<i class="m">-forXPath</i> is given, all CDATA sections in the nodes are
converted to text nodes, as a first step before the
normalization. </dd>
      

      
        <dt><b class="method">nodeType</b></dt>
        <dd>Returns the node type of the document node. This is always
DOCUMENT_NODE.</dd>
      

      
        <dt>
<b class="method">getElementById</b> <i class="m">id</i>
</dt>
        <dd>Returns the node having a id attribute with value
<i class="m">id</i> or the empty string, if no node has an id attribute with that value.</dd>
      

      
        <dt>
<b class="method">firstChild</b> <b class="variable">?objVar?</b>
</dt>
        <dd>Returns the first top level node of the document.</dd>
      

      
        <dt>
<b class="method">lastChild</b> <b class="variable">?objVar?</b>
</dt>
        <dd>Returns the last top level node of the document.</dd>
      

      
        <dt>
<b class="method">appendChild</b> <i class="m">newChild</i>
</dt>
        <dd>Append <i class="m">newChild</i> to the end of the list of top level nodes
of the document.</dd>
      

      
        <dt>
<b class="method">removeChild</b> <i class="m">child</i>
</dt>
        <dd>Removes <i class="m">child</i> from the list of top level nodes of the
document. <i class="m">child</i> will be part of the document fragment list
after this operation. It is not physically deleted.</dd>
      

      
        <dt><b class="method">hasChildNodes</b></dt>
        <dd>Returns 1 if the document has any nodes in the tree. Otherwise 0 is returned.</dd>
      

      
        <dt><b class="method">childNodes</b></dt>
        <dd>Returns a list of the top level nodes of the document.</dd>
      

      
        <dt>
<b class="method">ownerDocument</b> <b class="variable">?domObjVar?</b>
</dt>
        <dd>Returns the document itself.</dd>
      

      
        <dt>
<b class="method">insertBefore</b> <i class="m">newChild</i>  <i class="m">refChild</i>
</dt>
        <dd>Insert <i class="m">newChild</i> before the <i class="m">refChild</i> into the list of
top level nodes of the document. If <i class="m">refChild</i> is the empty string, inserts
<i class="m">newChild</i> at the end of the top level nodes.</dd>
      

      
        <dt>
<b class="method">replaceChild</b> <i class="m">newChild</i>  <i class="m">oldChild</i>
</dt>
        <dd>Replaces <i class="m">oldChild</i> with <i class="m">newChild</i> in the list of
children of that node. The <i class="m">oldChild</i> node will be part of the
document fragment list after this operation.</dd>
      

      
        <dt>
<b class="method">appendFromList</b> <i class="m">list</i>
</dt>
        <dd>Parses <i class="m">list</i> , creates an according DOM subtree and
appends this subtree at the end of the current list of top level nodes of the document.</dd>
      

      
        <dt>
<b class="method">appendXML</b> <i class="m">XMLstring</i>
</dt>
        <dd>Parses <i class="m">XMLstring</i>, creates an according DOM subtree and
appends this subtree at the end of the current list of top level nodes of the document.</dd>
      

      
          <dt>
<b class="method">selectNodes</b> <b class="option">?-namespaces prefixUriList?</b> <b class="option">?-cache &lt;boolean&gt;?</b> <i class="m">xpathQuery</i> <b class="option">?typeVar?</b>
</dt>
          <dd>
<p>Returns the result of applying the XPath query
<i class="m">xpathQuery</i> to the document. The context node of the query is the root
node in the sense of the XPath recommendation (not the document element). The
result can be a string/value, a list of strings, a list of nodes or a list
of attribute name / value pairs. If <i class="m">typeVar</i> is given
the result type name is stored into that variable (empty,
bool, number, string, nodes, attrnodes or mixed).</p>

<p>The argument <i class="m">xpathQuery</i> has to be a valid XPath
expression. However, there is one exception to that rule. Tcl variable
names can appear in the XPath statement at any position where it is
legal according to the rules of the XPath syntax to put an XPath
variable. The value of the variable is substituted for the variable
name. Ignoring the syntax rules of XPath the Tcl variable name may be
any legal Tcl var name: local variables, global variables, array
entries and so on.  The value will always be seen as string literal by
the xpath engine. Cast the value explicitly with the according xpath
functions (number(), boolean()) to another data type, if needed.</p>

<p>The option <i class="m">-namespaces</i> expects a tcl list with prefix /
namespace pairs as argument. If this option is not given, then any
namespace prefix within the xpath expression will be first resolved
against the list of prefix / namespace pairs set with the
selectNodesNamespaces method for the document the node belongs to. If
this fails, then the namespace definitions in scope of the context
node will be used to resolve the prefix. If this option is given, any
namespace prefix within the xpath expression will be first resolved
against that given list (and ignoring the document global prefix /
namespace list). If the list binds the same prefix to different
namespaces, then the first binding will win.  If this fails, then the
namespace definitions in scope of the context node will be used to
resolve the prefix, as usual.</p>

<p>If the <i class="m">-cache</i> option is used with a true value, then the
<i class="m">xpathQuery</i> will be looked up in a document specific cache. If
the query is found, then the stored pre-compiled query will be used.
If the query isn't found, it will be compiled and stored in the cache,
for use in further calls. Please notice, that the <i class="m">xpathQuery</i> as
given as string is used as key for the cache. This means that equal
XPath expressions, which differ only in white space, are treated as
different cache entries. Special care is needed if the XPath
expression includes namespace prefixes or references to tcl variables.
Both namespace prefixes and tcl variable references will be resolved
according to the XML prefix namespace mappings and tcl variable values
at expression compilation time. If the same XPath expression is used
later on in a context with other XML prefix namespace mappings or
values of the used tcl variables, make sure to first remove the
compiled expression from the cache with the help of the
<b class="method">deleteXPathCache</b> method, to force a recompilation.
Without using the <i class="m">-cache</i> option such consideration is never
needed.</p>

<p>Examples:</p>
          <pre class="example">set paragraphNodes [$node selectNodes {chapter[3]//para[@type='warning' or @type='error'} ]
foreach paragraph $paragraphNodes {
    lappend  values [$paragraph selectNodes attribute::type]
}

set doc [dom parse {&lt;doc xmlns="http://www.defaultnamespace.org"&gt;&lt;child/&gt;&lt;/doc&gt;}]
set root [$doc documentElement]
set childNodes [$root selectNodes -namespaces {default http://www.defaultnamespace.org} default:child]</pre>

          </dd>
      

      
        <dt>
<b class="method">baseURI</b> <i class="m">?URI?</i>
</dt>
        <dd>Returns the present baseURI of the document. If the optional 
argument URI is given, sets the base URI of the document to the given URI.</dd>
      

      
        <dt>
<b class="method">appendFromScript</b> <i class="m">tclScript</i>
</dt>
        <dd>Appends the nodes created by the <i class="m">tclScript</i> by
Tcl functions, which have been built using <i class="m">dom createNodeCmd</i>, at the end
of the current list of top level nodes of the document.</dd>
      

      
        <dt>
<b class="method">insertBeforeFromScript</b> <i class="m">tclScript</i> <i class="m">refChild</i>
</dt>
        <dd>Inserts the nodes created in the <i class="m">tclScript</i> by Tcl
functions, which have been built using <i class="m">dom
createNodeCmd</i>, before the <i class="m">refChild</i> into to the list
of top level nodes of the document. If <i class="m">refChild</i> is the
empty string, the new nodes will be appended.</dd>
      

      
        <dt>
<b class="method">deleteXPathCache</b> <i class="m">?xpathQuery?</i>
</dt>
        <dd>If called without the optional argument, all cached XPath
expressions of the document are freed. If called with the optional
argument <i class="m">xpathQuery</i>, this single XPath query will be removed
from the cache, if it is there. The method always returns an
empty string.</dd>
      

  </dl><p>Otherwise, if an unknown method name is given, the command with the
same name as the given method within the namespace <tt class="samp">::dom::domDoc</tt> is
tried to be executed. This allows quick method additions on Tcl level.</p><p>Newly created nodes are appended to a hidden fragment list. If they
are not moved into the tree they are automatically deleted as soon as the whole
document gets deleted.</p>

    <h2><a name="SECTid0x1efaea0">SEE ALSO</a></h2><p class="seealso">dom, domNode</p>

    <h2><a name="SECTid0x1efb230">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-DOMnodecreation">DOM node creation</a>, <a class="keyword" href="keyword-index.html#KW-documentelement">document element</a>
</p>

</div><hr class="navsep"><div class="navbar" align="center">
<a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a>
</div>
</body>
</html>