Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Integrated toXPath bug fix.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 85d99b56afae51a7e2129c3f06ee89f6d16fbaf6
User & Date: rolf 2013-09-20 23:44:47
Context
2013-09-24
00:20
Editorial change. check-in: 80ce5f7895 user: rolf tags: trunk
2013-09-21
23:44
Added dom method featureinfo. check-in: 2877d5b58a user: rolf tags: dom_featureinfo
2013-09-20
23:44
Integrated toXPath bug fix. check-in: 85d99b56af user: rolf tags: trunk
23:35
More tests. Minimal documentation. Closed-Leaf check-in: 9da0732eb4 user: rolf tags: toXPath
21:17
xslt.tcl better usable for memory debugging. check-in: 5bb0267890 user: rolf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/domNode.html.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
558
559
560
561
562
563
564
565

566
567
568

569
570
571
572
573
574
575
...
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domNode</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile$ $Revision$">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0x80a9a60">NAME</a> · <a href="#SECTid0x80a7378">SYNOPSIS</a> · <a href="#SECTid0x80967a8"> DESCRIPTION </a> · <a href="#SECTid0x80d2050">SEE ALSO</a> · <a href="#SECTid0x80d2270">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x80a9a60">NAME</a></h2><p class="namesection">
<b class="names">domNode - </b><br>Manipulates an instance of a DOM node object</p>



  <h2><a name="SECTid0x80a7378">SYNOPSIS</a></h2><pre class="syntax"> $nodeObject <i class="m">method</i>  <i class="m">arg arg ...</i>
</pre>
  <h2><a name="SECTid0x80967a8"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object.
<i class="m">method</i> indicates a specific method of the node 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>)
as well to parts of the W3C draft "XML Pointer Language (XPointer)"
(<a href="http://www.w3.org/TR/1998/WD-xptr-19980303">http://www.w3.org/TR/1998/WD-xptr-19980303</a>).
Please note, that the XPointer methods are deprecated. Use DOM methods
or XPath expressions instead of them.</p><p>The selectNodes method implements the "XML Path
................................................................................
        <dd>Translate the subtree starting at the object node according to
the specifications in <i class="m">specifications</i> and outputs the result in the
variable <i class="m">outputVar</i> . The translation is very similar to Cost Simple
mode.</dd>
      

      
        <dt><b class="method">toXPath</b></dt>

        <dd>Returns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one.</dd>

      

      
        <dt><b class="method">getBaseURI</b></dt>
        <dd>Returns the baseURI of the node. This method is deprecated in
          favor of the <i class="m">baseURI</i> method.</dd>
      
................................................................................
for <i class="m">getAttribute</i>.</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="l">::dom::domNode</tt> is tried to
be executed. This allows quick method additions on Tcl level.</p>


  <h2><a name="SECTid0x80d2050">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p>
  
  <h2><a name="SECTid0x80d2270">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</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>
</div>
</body>
</html>


|



|


|




|

|







 







|
>


|
>







 







|

|








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
...
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
<html>
<head>
<link rel="stylesheet" href="manpage.css"><title>tDOM manual: domNode</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $">
</head><body>
<div class="header">
<div class="navbar" align="center">
<a href="#SECTid0xb3b870">NAME</a> · <a href="#SECTid0xb53db0">SYNOPSIS</a> · <a href="#SECTid0xb5e220"> DESCRIPTION </a> · <a href="#SECTid0xba0550">SEE ALSO</a> · <a href="#SECTid0xba0920">KEYWORDS</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0xb3b870">NAME</a></h2><p class="namesection">
<b class="names">domNode - </b><br>Manipulates an instance of a DOM node object</p>



  <h2><a name="SECTid0xb53db0">SYNOPSIS</a></h2><pre class="syntax"> $nodeObject <i class="m">method</i>  <i class="m">arg arg ...</i>
</pre>
  <h2><a name="SECTid0xb5e220"> DESCRIPTION </a></h2><p>This command manipulates one particular instance of a DOM node object.
<i class="m">method</i> indicates a specific method of the node 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>)
as well to parts of the W3C draft "XML Pointer Language (XPointer)"
(<a href="http://www.w3.org/TR/1998/WD-xptr-19980303">http://www.w3.org/TR/1998/WD-xptr-19980303</a>).
Please note, that the XPointer methods are deprecated. Use DOM methods
or XPath expressions instead of them.</p><p>The selectNodes method implements the "XML Path
................................................................................
        <dd>Translate the subtree starting at the object node according to
the specifications in <i class="m">specifications</i> and outputs the result in the
variable <i class="m">outputVar</i> . The translation is very similar to Cost Simple
mode.</dd>
      

      
        <dt><b class="method">toXPath <i class="m">?-legacy?</i>
</b></dt>
        <dd>Returns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one. With the -legacy option, other XPath expressions
are returnd, which doesn't work in all cases.</dd>
      

      
        <dt><b class="method">getBaseURI</b></dt>
        <dd>Returns the baseURI of the node. This method is deprecated in
          favor of the <i class="m">baseURI</i> method.</dd>
      
................................................................................
for <i class="m">getAttribute</i>.</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="l">::dom::domNode</tt> is tried to
be executed. This allows quick method additions on Tcl level.</p>


  <h2><a name="SECTid0xba0550">SEE ALSO</a></h2><p class="seealso">dom, domDoc</p>
  
  <h2><a name="SECTid0xba0920">KEYWORDS</a></h2><p class="keywords">
<a class="keyword" href="keyword-index.html#KW-XML">XML</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-document">document</a>, <a class="keyword" href="keyword-index.html#KW-node">node</a>, <a class="keyword" href="keyword-index.html#KW-parsing">parsing</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>
</div>
</body>
</html>

Changes to doc/domNode.n.

533
534
535
536
537
538
539
540
541
542
543

544
545
546
547
548
549
550
.TP
\&\fB\fBsimpleTranslate\fP \fIoutputVar\fB \fIspecifications\fB
\&\fRTranslate the subtree starting at the object node according to
the specifications in \fIspecifications\fR and outputs the result in the
variable \fIoutputVar\fR . The translation is very similar to Cost Simple
mode.
.TP
\&\fB\fBtoXPath\fP
\&\fRReturns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one.

.TP
\&\fB\fBgetBaseURI\fP
\&\fRReturns the baseURI of the node. This method is deprecated in
favor of the \fIbaseURI\fR method.
.TP
\&\fB\fBbaseURI \fI?URI?\fB\fP
\&\fRReturns the present baseURI of the node. If the optional







|


|
>







533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
.TP
\&\fB\fBsimpleTranslate\fP \fIoutputVar\fB \fIspecifications\fB
\&\fRTranslate the subtree starting at the object node according to
the specifications in \fIspecifications\fR and outputs the result in the
variable \fIoutputVar\fR . The translation is very similar to Cost Simple
mode.
.TP
\&\fB\fBtoXPath \fI?-legacy?\fB\fP
\&\fRReturns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one. With the -legacy option, other XPath expressions
are returnd, which doesn't work in all cases.
.TP
\&\fB\fBgetBaseURI\fP
\&\fRReturns the baseURI of the node. This method is deprecated in
favor of the \fIbaseURI\fR method.
.TP
\&\fB\fBbaseURI \fI?URI?\fB\fP
\&\fRReturns the present baseURI of the node. If the optional

Changes to doc/domNode.xml.

494
495
496
497
498
499
500
501
502
503
504

505
506
507
508
509
510
511
        <desc>Translate the subtree starting at the object node according to
the specifications in <m>specifications</m> and outputs the result in the
variable <m>outputVar</m> . The translation is very similar to Cost Simple
mode.</desc>
      </commanddef>

      <commanddef>
        <command><method>toXPath</method></command>
        <desc>Returns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one.</desc>

      </commanddef>

      <commanddef>
        <command><method>getBaseURI</method></command>
        <desc>Returns the baseURI of the node. This method is deprecated in
          favor of the <m>baseURI</m> method.</desc>
      </commanddef>







|


|
>







494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
        <desc>Translate the subtree starting at the object node according to
the specifications in <m>specifications</m> and outputs the result in the
variable <m>outputVar</m> . The translation is very similar to Cost Simple
mode.</desc>
      </commanddef>

      <commanddef>
        <command><method>toXPath <m>?-legacy?</m></method></command>
        <desc>Returns an XPath, which exactly addresses the given
node in its document. This XPath is only valid as there are no changes to DOM
tree made later one. With the -legacy option, other XPath expressions
are returnd, which doesn't work in all cases.</desc>
      </commanddef>

      <commanddef>
        <command><method>getBaseURI</method></command>
        <desc>Returns the baseURI of the node. This method is deprecated in
          favor of the <m>baseURI</m> method.</desc>
      </commanddef>

Changes to generic/domxpath.c.

5777
5778
5779
5780
5781
5782
5783
5784

5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805

5806
















5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817

5818
5819
5820
5821
5822
5823
5824
....
5860
5861
5862
5863
5864
5865
5866
5867

5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
|   nodeToXPath  -  returns a XPath addressing exactly the given node
|
\---------------------------------------------------------------------------*/
static void nodeToXPath (
    domNode  * node,
    char    ** xpath,
    int      * xpathLen,
    int      * xpathAllocated

)
{
    domNode *parent, *child;
    char    step[200], *nTest;
    int     sameNodes, nodeIndex, len;


    parent = node->parentNode;
    if (parent == NULL) {
        parent = node->ownerDocument->rootNode;
    } else {
        nodeToXPath (parent, xpath, xpathLen, xpathAllocated);
    }

    step[0] = '\0';
    switch (node->nodeType) {

    case ELEMENT_NODE:
        nodeIndex = 0;
        sameNodes = 0;
        child = parent->firstChild;

        while (child) {
















            if (strcmp(child->nodeName, node->nodeName)==0) {
                sameNodes++;
                if (node == child) nodeIndex = sameNodes;
                if ((nodeIndex != 0) && (sameNodes > 2)) break;
            }
            child = child->nextSibling;
        }
        if (sameNodes == 1) {
            sprintf(step, "/%s", node->nodeName);
        } else {
            sprintf(step, "/%s[%d]", node->nodeName, nodeIndex);

        }
        break;

    case TEXT_NODE:
    case COMMENT_NODE:
    case PROCESSING_INSTRUCTION_NODE:
        nodeIndex = 0;
................................................................................


/*----------------------------------------------------------------------------
|   xpathNodeToXPath
|
\---------------------------------------------------------------------------*/
char * xpathNodeToXPath (
    domNode *node

)
{
    char  * xpath;
    int     xpathLen, xpathAllocated;


    xpathAllocated = 100;
    xpathLen       = 0;
    xpath          = MALLOC(xpathAllocated + 1);

    nodeToXPath (node, &xpath, &xpathLen, &xpathAllocated);

    return xpath;

} /* xpathNodeToXPath */








|
>











|









>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
>







 







|
>










|





5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
....
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
|   nodeToXPath  -  returns a XPath addressing exactly the given node
|
\---------------------------------------------------------------------------*/
static void nodeToXPath (
    domNode  * node,
    char    ** xpath,
    int      * xpathLen,
    int      * xpathAllocated,
    int        legacy
)
{
    domNode *parent, *child;
    char    step[200], *nTest;
    int     sameNodes, nodeIndex, len;


    parent = node->parentNode;
    if (parent == NULL) {
        parent = node->ownerDocument->rootNode;
    } else {
        nodeToXPath (parent, xpath, xpathLen, xpathAllocated, legacy);
    }

    step[0] = '\0';
    switch (node->nodeType) {

    case ELEMENT_NODE:
        nodeIndex = 0;
        sameNodes = 0;
        child = parent->firstChild;
        if (node->namespace && !legacy) {
            while (child) {
                if (child->nodeType == ELEMENT_NODE) {
                    sameNodes++;
                    if (node == child) {
                        nodeIndex = sameNodes;
                        if (sameNodes > 1) break;
                    }
                }
                child = child->nextSibling;
            }
            if (sameNodes == 1) {
                sprintf(step, "/*");
            } else {
                sprintf(step, "/*[%d]", nodeIndex);
            }
        } else {
            while (child) {
                if (strcmp(child->nodeName, node->nodeName)==0) {
                    sameNodes++;
                    if (node == child) nodeIndex = sameNodes;
                    if ((nodeIndex != 0) && (sameNodes > 2)) break;
                }
                child = child->nextSibling;
            }
            if (sameNodes == 1) {
                sprintf(step, "/%s", node->nodeName);
            } else {
                sprintf(step, "/%s[%d]", node->nodeName, nodeIndex);
            }
        }
        break;

    case TEXT_NODE:
    case COMMENT_NODE:
    case PROCESSING_INSTRUCTION_NODE:
        nodeIndex = 0;
................................................................................


/*----------------------------------------------------------------------------
|   xpathNodeToXPath
|
\---------------------------------------------------------------------------*/
char * xpathNodeToXPath (
    domNode *node,
    int      legacy
)
{
    char  * xpath;
    int     xpathLen, xpathAllocated;


    xpathAllocated = 100;
    xpathLen       = 0;
    xpath          = MALLOC(xpathAllocated + 1);

    nodeToXPath (node, &xpath, &xpathLen, &xpathAllocated, legacy);

    return xpath;

} /* xpathNodeToXPath */

Changes to generic/domxpath.h.

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
double xpathFuncNumber   (xpathResultSet *rs, int *NaN);
char * xpathFuncString   (xpathResultSet *rs); 
char * xpathFuncStringForNode (domNode *node);
int    xpathRound        (double r);

char * xpathGetStringValue (domNode *node, int *strLen);

char * xpathNodeToXPath  (domNode *node);
    
void rsSetBool      ( xpathResultSet *rs, int          i    );
void rsSetInt       ( xpathResultSet *rs, int          i    );
void rsSetReal      ( xpathResultSet *rs, double       d    );
void rsSetString    ( xpathResultSet *rs, const char  *s    );
void rsAddNode      ( xpathResultSet *rs, domNode     *node );
void rsAddNodeFast  ( xpathResultSet *rs, domNode     *node );







|







194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
double xpathFuncNumber   (xpathResultSet *rs, int *NaN);
char * xpathFuncString   (xpathResultSet *rs); 
char * xpathFuncStringForNode (domNode *node);
int    xpathRound        (double r);

char * xpathGetStringValue (domNode *node, int *strLen);

char * xpathNodeToXPath  (domNode *node, int legacy);
    
void rsSetBool      ( xpathResultSet *rs, int          i    );
void rsSetInt       ( xpathResultSet *rs, int          i    );
void rsSetReal      ( xpathResultSet *rs, double       d    );
void rsSetString    ( xpathResultSet *rs, const char  *s    );
void rsAddNode      ( xpathResultSet *rs, domNode     *node );
void rsAddNodeFast  ( xpathResultSet *rs, domNode     *node );

Changes to generic/tcldom.c.

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
....
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
....
3802
3803
3804
3805
3806
3807
3808
3809









3810
3811
3812
3813
3814
3815
3816
3817
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                       \n"
    "    appendFromList nestedList    \n"
    "    appendFromScript script      \n"
    "    insertBeforeFromScript script ref \n"
    "    appendXML xmlString          \n"
    "    selectNodes ?-namespaces prefixUriList? ?-cache <boolean>? xpathQuery ?typeVar? \n"
    "    toXPath                      \n"
    "    disableOutputEscaping ?boolean? \n"
    "    precedes node                \n"
    "    normalize ?-forXPath?        \n"
    "    xslt ?-parameters parameterList? <xsltDocNode>\n"
    TDomThreaded(
    "    readlock                     \n"
    "    writelock                    \n"
................................................................................
    domAttrNode *attrs;
    domException exception;
    char         tmp[200], objCmdName[80], prefix[MAX_PREFIX_LEN],
                *method, *nodeName, *str, *attr_name, *attr_val, *filter,
                *errMsg;
    const char  *localName, *uri, *nsStr;
    int          result, length, methodIndex, i, line, column;
    int          nsIndex, bool, hnew;
    Tcl_Obj     *namePtr, *resultPtr;
    Tcl_Obj     *mobjv[MAX_REWRITE_ARGS];
    Tcl_CmdInfo  cmdInfo;
    Tcl_HashEntry *h;

    static CONST84 char *nodeMethods[] = {
        "firstChild",      "nextSibling",    "getAttribute",    "nodeName",
................................................................................
    /*----------------------------------------------------------------------
    |   dispatch the node object method
    |
    \---------------------------------------------------------------------*/
    switch ((enum nodeMethod)methodIndex) {

        case m_toXPath:
            CheckArgs(2,2,2,"");









            str = xpathNodeToXPath(node);
            SetResult (str);
            FREE (str);
            return TCL_OK;

        case m_xslt:
            CheckArgs(3,9,2, "?-parameters parameterList? "
                      "?-ignoreUndeclaredParameters? ?-xsltmessagecmd cmd? "







|







 







|







 







|
>
>
>
>
>
>
>
>
>
|







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
....
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
....
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
    "    asHTML ?-channel <channelId>? ?-escapeNonASCII? ?-htmlEntities?\n"
    "    asText                       \n"
    "    appendFromList nestedList    \n"
    "    appendFromScript script      \n"
    "    insertBeforeFromScript script ref \n"
    "    appendXML xmlString          \n"
    "    selectNodes ?-namespaces prefixUriList? ?-cache <boolean>? xpathQuery ?typeVar? \n"
    "    toXPath ?-legacy?            \n"
    "    disableOutputEscaping ?boolean? \n"
    "    precedes node                \n"
    "    normalize ?-forXPath?        \n"
    "    xslt ?-parameters parameterList? <xsltDocNode>\n"
    TDomThreaded(
    "    readlock                     \n"
    "    writelock                    \n"
................................................................................
    domAttrNode *attrs;
    domException exception;
    char         tmp[200], objCmdName[80], prefix[MAX_PREFIX_LEN],
                *method, *nodeName, *str, *attr_name, *attr_val, *filter,
                *errMsg;
    const char  *localName, *uri, *nsStr;
    int          result, length, methodIndex, i, line, column;
    int          nsIndex, bool, hnew, legacy;
    Tcl_Obj     *namePtr, *resultPtr;
    Tcl_Obj     *mobjv[MAX_REWRITE_ARGS];
    Tcl_CmdInfo  cmdInfo;
    Tcl_HashEntry *h;

    static CONST84 char *nodeMethods[] = {
        "firstChild",      "nextSibling",    "getAttribute",    "nodeName",
................................................................................
    /*----------------------------------------------------------------------
    |   dispatch the node object method
    |
    \---------------------------------------------------------------------*/
    switch ((enum nodeMethod)methodIndex) {

        case m_toXPath:
            CheckArgs(2,3,2,"?-legacy?");
            legacy = 0;
            if (objc == 3) {
                if (!strcmp(Tcl_GetString(objv[2]), "-legacy")) {
                    legacy = 1;
                } else {
                    SetResult("unknown option! Options: ?-legacy?");
                    return TCL_ERROR;
                }
            }
            str = xpathNodeToXPath(node, legacy);
            SetResult (str);
            FREE (str);
            return TCL_OK;

        case m_xslt:
            CheckArgs(3,9,2, "?-parameters parameterList? "
                      "?-ignoreUndeclaredParameters? ?-xsltmessagecmd cmd? "

Changes to tests/domNode.test.

3182
3183
3184
3185
3186
3187
3188






























































































































3189
3190
3191
3192
3193
3194
3195
    set result {}
    foreach toplevelcomment [$doc selectNodes /comment()] {
        lappend result [$toplevelcomment toXPath]
    }
    $doc delete
    set result
} [list {/comment()[1]} {/comment()[2]} {/comment()[3]}]































































































































test domNode-39.1 {text} {
     set doc [dom parse {<root>text <b>bold</b> more text</root>}]
     $doc documentElement root
     set result [$root text]
     $doc delete
     set result







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
    set result {}
    foreach toplevelcomment [$doc selectNodes /comment()] {
        lappend result [$toplevelcomment toXPath]
    }
    $doc delete
    set result
} [list {/comment()[1]} {/comment()[2]} {/comment()[3]}]

test domNode-38.3 {toXPath - syntax} -setup {
    set doc [dom parse <doc/>]
    set root [$doc documentElement]
} -body {
    catch {$root toXPath foo bar} errMsg
    set errMsg
} -cleanup {
    $doc delete
} -match regexp -result {wrong # args: should be "domNode0x[[:xdigit:]]+ toXPath \?-legacy\?"}

test domNode0-38.4 {toXPath - default xml namespace} -setup {
    set doc [dom parse {<root><foo xmlns="foo"/><foo/></root>}]
    $doc selectNodesNamespaces {foo foo}
    set root [$doc documentElement]
    set foo1 [$root selectNodes foo:foo]
    set xfo1 [$foo1 toXPath]
} -body {
    expr {$foo1 == [[$foo1 ownerDocument] selectNodes [$foo1 toXPath]]}
} -cleanup {
    $doc delete
} -result 1

test domNode0-38.5 {toXPath - default xml namespace} -setup {
    set doc [dom parse {
<root xmlns="foo">
    <!-- comment -->
    <foo/>
    some text    
    <foo/>
    <?mypi data?>
    <foo/>
</root>}]
    set root [$doc documentElement]
    $doc selectNodesNamespaces {foo foo}
    set foo2 [$root selectNodes {foo:foo[2]}]
} -body {
    expr {$foo2 == [[$foo2 ownerDocument] selectNodes [$foo2 toXPath]]}
} -cleanup {
    $doc delete
} -result 1

test domNode0-38.6 {toXPath - xml namespace} -setup {
    set doc [dom parse {
<root xmlns:foo="foo">
    <!-- comment -->
    <foo:foo/>
    some text    
    <foo:foo/>
    <?mypi data?>
    <foo:foo/>
</root>}]
    set root [$doc documentElement]
    $doc selectNodesNamespaces {foo foo}
    set foo2 [$root selectNodes {foo:foo[2]}]
} -body {
    expr {$foo2 == [[$foo2 ownerDocument] selectNodes [$foo2 toXPath]]}
} -cleanup {
    $doc delete
} -result 1

test domNode0-38.7 {toXPath - pathological xml namespace} -setup {
    set doc [dom parse {
<root>
    <!-- comment -->
    <foo:foo xmlns:foo="foo"/>
    some text    
    <foo:foo xmlns:foo="bar"/>
    <?mypi data?>
    <foo:foo xmlns:foo="bar"/>
    <foo:foo xmlns:foo="foo"/>
</root>}]
    set root [$doc documentElement]
    $doc selectNodesNamespaces {foo foo}
    set foo2 [$root selectNodes {foo:foo[2]}]
} -body {
    expr {$foo2 == [[$foo2 ownerDocument] selectNodes [$foo2 toXPath]]}
} -cleanup {
    $doc delete
} -result 1

test domNode0-38.8 {toXPath - pathological xml namespace} -setup {
    set doc [dom parse {
<root>
    <!-- comment -->
    <foo:foo xmlns:foo="foo">
        <bar/>
        text
        <bar xmlns=""/>
    </foo:foo>
    some text    
    <foo:foo xmlns:foo="bar"/>
    <?mypi data?>
    <foo:foo xmlns:foo="bar"/>
    <foo:foo xmlns:foo="foo">
        <bar/>
        <foo:foo xmlns:foo="bar"/>
        text
        <bar xmlns=""/>
    </foo:foo>
    <foo:foo xmlns:foo="foo"/>
</root>}]
} -body {
    set result ""
    foreach node [$doc selectNodes //node()] {
        if {$node != [[$node ownerDocument] selectNodes [$node toXPath]]} {
            set result [$node toXPath]
            break
        }
    }
    set result
} -cleanup {
    $doc delete
} -result ""

test domNode0-38.9 {toXPath - really long element name} -constraints {
    knownBug
} -setup {
    set doc [dom parse "<doc><[string repeat abc 100]/></doc>"]
    set root [$doc documentElement]
    set firstChild [$root firstChild]
} -body {
    $firstChild toXPath
} -cleanup {
    $doc delete
} -result "/doc/[string repeat abc 100]"

test domNode-39.1 {text} {
     set doc [dom parse {<root>text <b>bold</b> more text</root>}]
     $doc documentElement root
     set result [$root text]
     $doc delete
     set result