summaryrefslogtreecommitdiff
path: root/test/testcases/tests/level3/xpath/Text_Nodes.xml
blob: 4897c12e4cfffa34854b95313b392b210827c33e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
<!--
 Copyright (c) 2003 World Wide Web Consortium,

 (Massachusetts Institute of Technology, European Research Consortium for
 Informatics and Mathematics, Keio University). All Rights Reserved. This
 work is distributed under the W3C(r) Software License [1] in the hope that
 it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-->

<!DOCTYPE test SYSTEM "dom3.dtd" [
  <!ENTITY % entities SYSTEM "dom3xpathents.ent">
  %entities;
]>
<test xmlns="&level3;" name="Text_Nodes">
  <metadata>
    <title>Text_Nodes</title>
    <creator>Bob Clary</creator>
    <description>
      1.2.4 Text Nodes - 
      Create ANY_TYPE XPathResult matching //text(),
      check that each matching Node is a Text Node, and
      that no pair of nodes in the result are siblings.
    </description>
    <date qualifier="created">2003-12-02</date>
    <subject resource="&spec;#Mapping"/>
    <subject resource="&spec;#XPathEvaluator"/>
    <subject resource="&spec;#XPathEvaluator-createNSResolver"/>
    <subject resource="&spec;#XPathEvaluator-evaluate"/>
    <subject resource="&spec;#XPathNSResolver"/>
    <subject resource="&spec;#XPathResult"/>
    <subject resource="&spec;#XPathResult-iterateNext"/>
  </metadata>

  <!-- Standard Variables -->

  <var name="ANY_TYPE"                     type="short" value="0"/>
  <var name="NUMBER_TYPE"                  type="short" value="1"/>
  <var name="STRING_TYPE"                  type="short" value="2"/>
  <var name="BOOLEAN_TYPE"                 type="short" value="3"/>
  <var name="UNORDERED_NODE_ITERATOR_TYPE" type="short" value="4"/>
  <var name="ORDERED_NODE_ITERATOR_TYPE"   type="short" value="5"/>
  <var name="UNORDERED_NODE_SNAPSHOT_TYPE" type="short" value="6"/>
  <var name="ORDERED_NODE_SNAPSHOT_TYPE"   type="short" value="7"/>
  <var name="ANY_UNORDERED_NODE_TYPE"      type="short" value="8"/>
  <var name="FIRST_ORDERED_NODE_TYPE"      type="short" value="9"/>

  <var name="doc"                 type="Document" />
  <var name="resolver"            type="XPathNSResolver" />
  <var name="evaluator"           type="XPathEvaluator" />
  <var name="contextNode"         type="Node" />
  <var name="inresult"            type="XPathResult" isNull="true"/>
  <var name="outresult"           type="XPathResult" isNull="true"/>

  <!-- Inputs -->

  <var name="expression" type="DOMString" value="&quot;//text()&quot;" />
  <var name="xpathType"  type="short"     value="ANY_TYPE" />

  <!-- Test Variables -->

  <var name="currNode"            type="Node"/>
  <var name="nextNode"            type="Node"/>
  <var name="currNodeNextSibling" type="Node"/>
  <var name="nextNodePrevSibling" type="Node"/>
  <var name="nodeType"            type="int"/>
  <var name="isTextNode"          type="DOMString" />

  <!-- Load Test Document -->

  <load var="doc" href="staff" willBeModified="true"/>

  <!-- Get XPathResult -->

  <createXPathEvaluator var="evaluator" document="doc" />
  <createNSResolver var="resolver" obj="evaluator" nodeResolver="doc" />

  <assign var="contextNode" value="doc"/>

  <evaluate obj="evaluator"
            var="outresult"
            expression="expression"
            contextNode="contextNode"
            resolver="resolver"
            type="xpathType"
            result="inresult"
            interface="XPathEvaluator" />

  <!-- Test Body -->

  <iterateNext var="currNode" obj="outresult" /> 

  <while> <notNull obj="currNode"/>

    <nodeType var="nodeType" obj="currNode" />

    <assign var="isTextNode" value="&quot;true&quot;"/>
    <if>
      <and>
        <notEquals actual="nodeType" expected="3"/>
        <notEquals actual="nodeType" expected="4"/>
      </and>

      <assign var="isTextNode" value="&quot;false&quot;"/>
    </if>
    <assertEquals id="S1.2.4-Text-Nodes-nodeType" 
                  actual="isTextNode" 
                  expected="&quot;true&quot;" 
                  ignoreCase="true"/>

    <iterateNext var="nextNode" obj="outresult"/> 

    <if>
      <notNull obj="nextNode"/>

      <nextSibling var="currNodeNextSibling" 
                   obj="currNode" interface="Node"/>
      <if>
        <same actual="currNodeNextSibling" expected="nextNode"/>
	  <comment>dummy statement</comment>
        <else>
          <assertTrue id="S1.2.4-Text-Nodes-Adjacent-Next" 
	              actual="false"
		      />
        </else>
      </if>

      <previousSibling var="nextNodePrevSibling" 
                       obj="nextNode" interface="Node"/>
      <if>
        <same actual="currNode" expected="nextNodePrevSibling"/>
	  <comment>dummy statement</comment>
        <else>
          <assertTrue id="S1.2.4-Text-Nodes-Adjacent-Prev" 
	              actual="false" 
		      />
        </else>
      </if>

    </if>

    <assign var="currNode" value="nextNode"/>

  </while>

</test>