/
index.html
11832 lines (11821 loc) · 463 KB
/
index.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org" />
<title>XML Path Language (XPath) 2.0</title>
<style type="text/css">
/*<![CDATA[*/
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
div.issue
p.title { margin-left: -2em; }
ol.enumar { list-style-type: decimal; }
ol.enumla { list-style-type: lower-alpha; }
ol.enumlr { list-style-type: lower-roman; }
ol.enumua { list-style-type: upper-alpha; }
ol.enumur { list-style-type: upper-roman; }
li p { margin-top: 0.3em;
margin-bottom: 0.3em; }
sup small { font-style: italic;
color: #8F8F8F;
}
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
div.issue { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
margin-bottom: 20pt;
}
th.issue-toc-head { border-bottom-color: black;
border-bottom-style: solid;
border-bottom-width: 1pt;
}
table.small { font-size: x-small; }
/*]]>*/
</style>
<link type="text/css" rel="stylesheet" href=
"http://www.w3.org/StyleSheets/TR/W3C-REC.css" />
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img width="72" height="48" alt=
"W3C" src="http://www.w3.org/Icons/w3c_home" /></a></p>
<h1><a id="title" name="title"></a>XML Path Language (XPath)
2.0</h1>
<h2><a id="w3c-doctype" name="w3c-doctype"></a>W3C Recommendation
23 January 2007</h2>
<dl>
<dt>This version:</dt>
<dd><span class="xpath"><a href=
"http://www.w3.org/TR/2007/REC-xpath20-20070123/">http://www.w3.org/TR/2007/REC-xpath20-20070123/</a></span></dd>
<dt>Latest version:</dt>
<dd><span class="xpath"><a href=
"http://www.w3.org/TR/xpath20/">http://www.w3.org/TR/xpath20/</a></span></dd>
<dt>Previous version:</dt>
<dd><span class="xpath"><a href=
"http://www.w3.org/TR/2006/PR-xpath20-20061121/">http://www.w3.org/TR/2006/PR-xpath20-20061121/</a></span></dd>
<dt>Editors:</dt>
<dd class="xpath">Anders Berglund (XSL WG), IBM Research <a href=
"mailto:alrb@us.ibm.com"><alrb@us.ibm.com></a></dd>
<dd>Scott Boag (XSL WG), IBM Research <a href=
"mailto:scott_boag@us.ibm.com"><scott_boag@us.ibm.com></a></dd>
<dd>Don Chamberlin (XML Query WG), IBM Almaden Research Center, via
<a href=
"http://www.almaden.ibm.com/cs/people/chamberlin/">http://www.almaden.ibm.com/cs/people/chamberlin/</a></dd>
<dd>Mary F. Fernández (XML Query WG), AT&T Labs <a href=
"mailto:mff@research.att.com"><mff@research.att.com></a></dd>
<dd class="xpath">Michael Kay (XSL WG), Saxonica, via <a href=
"http://www.saxonica.com/">http://www.saxonica.com/</a></dd>
<dd>Jonathan Robie (XML Query WG), <span><a href=
"http://www.xquery.com">DataDirect Technologies</a></span>, via
<a href=
"http://www.ibiblio.org/jwrobie/">http://www.ibiblio.org/jwrobie/</a></dd>
<dd>Jérôme Siméon (XML Query WG), IBM T.J. Watson Research Center
<a href=
"mailto:simeon@us.ibm.com"><simeon@us.ibm.com></a></dd>
</dl>
<p>Please refer to the <a href=
"http://www.w3.org/XML/2007/qt-errata/xpath20-errata.html"><strong>errata</strong></a>
for this document, which may include some normative
corrections.</p>
<p>See also <a href=
"http://www.w3.org/2003/03/Translations/byTechnology?technology=xpath20">
<strong>translations</strong></a>.</p>
<p>This document is also available in these non-normative formats:
<span class="xpath"><a href=
"http://www.w3.org/TR/2007/REC-xpath20-20070123/xpath20.xml">XML</a></span>.</p>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2007 <a href="http://www.w3.org/">
<acronym title=
"World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href=
"http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.org/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href=
"http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
</div>
<hr />
<div>
<h2><a id="abstract" name="abstract"></a>Abstract</h2>
<div class="xpath">
<p class="xpath">XPath 2.0 is an expression language that allows
the processing of values conforming to the data model defined in
<a href="#datamodel">[XQuery/XPath Data Model (XDM)]</a>. The data
model provides a tree representation of XML documents as well as
atomic values such as integers, strings, and booleans, and
sequences that may contain both references to nodes in an XML
document and atomic values. The result of an XPath expression may
be a selection of nodes from the input documents, or an atomic
value, or more generally, any sequence allowed by the data model.
The name of the language derives from its most distinctive feature,
the path expression, which provides a means of hierarchic
addressing of the nodes in an XML tree. XPath 2.0 is a superset of
<a href="#XPath">[XPath 1.0]</a>, with the added capability to
support a richer set of data types, and to take advantage of the
type information that becomes available when documents are
validated using XML Schema. A backwards compatibility mode is
provided to ensure that nearly all XPath 1.0 expressions continue
to deliver the same result with XPath 2.0; exceptions to this
policy are noted in [<a href="#id-backwards-compatibility"><b>I
Backwards Compatibility with XPath 1.0</b></a>].</p>
</div>
</div>
<div>
<h2><a id="status" name="status"></a>Status of this Document</h2>
<p><em>This section describes the status of this document at the
time of its publication. Other documents may supersede this
document. A list of current W3C publications and the latest
revision of this technical report can be found in the <a href=
"http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This is one document in a set of eight documents that have
progressed to Recommendation together (XQuery 1.0, XQueryX 1.0,
XSLT 2.0, Data Model, Functions and Operators, Formal Semantics,
Serialization, XPath 2.0).</p>
<p>This is a <a href=
"http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">Recommendation</a>
of the W3C. It <span class="xpath"><span class="xpath">has been
jointly developed by the W3C <a href=
"http://www.w3.org/Style/XSL">XSL Working Group</a> and the W3C
<a href="http://www.w3.org/XML/Query">XML Query Working Group</a>,
each of which is part of the <a href=
"http://www.w3.org/XML/Activity">XML
Activity</a>.</span></span></p>
<p>This document has been reviewed by W3C Members, by software
developers, and by other W3C groups and interested parties, and is
endorsed by the Director as a W3C Recommendation. It is a stable
document and may be used as reference material or cited from
another document. W3C's role in making the Recommendation is to
draw attention to the specification and to promote its widespread
deployment. This enhances the functionality and interoperability of
the Web.</p>
<p><span class="xpath"><span class="xpath">No substantive changes
have been made to this specification since its publication as a
Proposed Recommendation.</span></span></p>
<p>Please report errors in this document using W3C's <a href=
"http://www.w3.org/Bugs/Public/">public Bugzilla system</a>
(instructions can be found at <a href=
"http://www.w3.org/XML/2005/04/qt-bugzilla">http://www.w3.org/XML/2005/04/qt-bugzilla</a>).
If access to that system is not feasible, you may send your
comments to the W3C XSLT/XPath/XQuery public comments mailing list,
<a href=
"mailto:public-qt-comments@w3.org">public-qt-comments@w3.org</a>.
It will be very helpful if you include the string “[<span class=
"xpath"><span class="xpath">XPath</span></span>]” in the subject
line of your report, whether made in Bugzilla or in email. Each
Bugzilla entry and email message should contain only one error
report. Archives of the comments and responses are available at
<a href=
"http://lists.w3.org/Archives/Public/public-qt-comments/">http://lists.w3.org/Archives/Public/public-qt-comments/</a>.</p>
<p>This document was produced by <span class="xpath"><span class=
"xpath">groups</span></span> operating under the <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/18797/status#disclosures">public
list of any patent disclosures</a> made in connection with the
deliverables of the <span class="xpath"><span class="xpath">XML
Query Working Group</span></span> <span class="xpath"><span class=
"xpath">and also maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/19552/status#disclosures">public
list of any patent disclosures</a> made in connection with the
deliverables of the XSL Working Group; those pages also
include</span></span> instructions for disclosing a patent. An
individual who has actual knowledge of a patent which the
individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">
Essential Claim(s)</a> must disclose the information in accordance
with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">
section 6 of the W3C Patent Policy</a>.</p>
</div>
<div class="toc">
<h2><a id="contents" name="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#id-introduction">Introduction</a><br />
2 <a href="#id-basics">Basics</a><br />
    2.1 <a href="#context">Expression
Context</a><br />
        2.1.1 <a href=
"#static_context">Static Context</a><br />
        2.1.2 <a href=
"#eval_context">Dynamic Context</a><br />
    2.2 <a href=
"#id-processing-model">Processing Model</a><br />
        2.2.1 <a href=
"#id-data-model-generation">Data Model Generation</a><br />
        2.2.2 <a href=
"#id-schema-import-processing">Schema Import Processing</a><br />
        2.2.3 <a href=
"#id-expression-processing">Expression Processing</a><br />
            2.2.3.1
<a href="#id-static-analysis">Static Analysis Phase</a><br />
            2.2.3.2
<a href="#id-dynamic-evaluation">Dynamic Evaluation Phase</a><br />
        2.2.4 <a href=
"#id-serialization">Serialization</a><br />
        2.2.5 <a href=
"#id-consistency-constraints">Consistency Constraints</a><br />
    2.3 <a href="#errors">Error
Handling</a><br />
        2.3.1 <a href=
"#id-kinds-of-errors">Kinds of Errors</a><br />
        2.3.2 <a href=
"#id-identifying-errors">Identifying and Reporting Errors</a><br />
        2.3.3 <a href=
"#id-handling-dynamic">Handling Dynamic Errors</a><br />
        2.3.4 <a href=
"#id-errors-and-opt">Errors and Optimization</a><br />
    2.4 <a href=
"#id-important-concepts">Concepts</a><br />
        2.4.1 <a href=
"#id-document-order">Document Order</a><br />
        2.4.2 <a href=
"#id-atomization">Atomization</a><br />
        2.4.3 <a href=
"#id-ebv">Effective Boolean Value</a><br />
        2.4.4 <a href=
"#id-input-sources">Input Sources</a><br />
    2.5 <a href="#id-types">Types</a><br />
        2.5.1 <a href=
"#id-predefined-types">Predefined Schema Types</a><br />
        2.5.2 <a href=
"#id-typed-value">Typed Value and String Value</a><br />
        2.5.3 <a href=
"#id-sequencetype-syntax">SequenceType Syntax</a><br />
        2.5.4 <a href=
"#id-sequencetype-matching">SequenceType Matching</a><br />
            2.5.4.1
<a href="#id-matching-value">Matching a SequenceType and a
Value</a><br />
            2.5.4.2
<a href="#id-matching-item">Matching an ItemType and an
Item</a><br />
            2.5.4.3
<a href="#id-element-test">Element Test</a><br />
            2.5.4.4
<a href="#id-schema-element-test">Schema Element Test</a><br />
            2.5.4.5
<a href="#id-attribute-test">Attribute Test</a><br />
            2.5.4.6
<a href="#id-schema-attribute-test">Schema Attribute Test</a><br />
    2.6 <a href="#comments">Comments</a><br />
3 <a href="#id-expressions">Expressions</a><br />
    3.1 <a href=
"#id-primary-expressions">Primary Expressions</a><br />
        3.1.1 <a href=
"#id-literals">Literals</a><br />
        3.1.2 <a href=
"#id-variables">Variable References</a><br />
        3.1.3 <a href=
"#id-paren-expressions">Parenthesized Expressions</a><br />
        3.1.4 <a href=
"#id-context-item-expression">Context Item Expression</a><br />
        3.1.5 <a href=
"#id-function-calls">Function Calls</a><br />
    3.2 <a href="#id-path-expressions">Path
Expressions</a><br />
        3.2.1 <a href=
"#id-steps">Steps</a><br />
            3.2.1.1
<a href="#axes">Axes</a><br />
            3.2.1.2
<a href="#node-tests">Node Tests</a><br />
        3.2.2 <a href=
"#id-predicates">Predicates</a><br />
        3.2.3 <a href=
"#unabbrev">Unabbreviated Syntax</a><br />
        3.2.4 <a href=
"#abbrev">Abbreviated Syntax</a><br />
    3.3 <a href=
"#id-sequence-expressions">Sequence Expressions</a><br />
        3.3.1 <a href=
"#construct_seq">Constructing Sequences</a><br />
        3.3.2 <a href=
"#id-filter-expr">Filter Expressions</a><br />
        3.3.3 <a href=
"#combining_seq">Combining Node Sequences</a><br />
    3.4 <a href="#id-arithmetic">Arithmetic
Expressions</a><br />
    3.5 <a href="#id-comparisons">Comparison
Expressions</a><br />
        3.5.1 <a href=
"#id-value-comparisons">Value Comparisons</a><br />
        3.5.2 <a href=
"#id-general-comparisons">General Comparisons</a><br />
        3.5.3 <a href=
"#id-node-comparisons">Node Comparisons</a><br />
    3.6 <a href=
"#id-logical-expressions">Logical Expressions</a><br />
    3.7 <a href="#id-for-expressions">For
Expressions</a><br />
    3.8 <a href="#id-conditionals">Conditional
Expressions</a><br />
    3.9 <a href=
"#id-quantified-expressions">Quantified Expressions</a><br />
    3.10 <a href=
"#id-expressions-on-datatypes">Expressions on
SequenceTypes</a><br />
        3.10.1 <a href=
"#id-instance-of">Instance Of</a><br />
        3.10.2 <a href=
"#id-cast">Cast</a><br />
        3.10.3 <a href=
"#id-castable">Castable</a><br />
        3.10.4 <a href=
"#id-constructor-functions">Constructor Functions</a><br />
        3.10.5 <a href=
"#id-treat">Treat</a><br /></p>
<h3><a id="appendices" name="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#nt-bnf">XPath Grammar</a><br />
    A.1 <a href="#id-grammar">EBNF</a><br />
        A.1.1 <a href=
"#EBNFNotation">Notation</a><br />
        A.1.2 <a href=
"#extra-grammatical-constraints">Extra-grammatical
Constraints</a><br />
        A.1.3 <a href=
"#notes-on-parsing">Grammar Notes</a><br />
    A.2 <a href="#lexical-structure">Lexical
structure</a><br />
        A.2.1 <a href=
"#terminal-symbols">Terminal Symbols</a><br />
        A.2.2 <a href=
"#id-terminal-delimitation">Terminal Delimitation</a><br />
        A.2.3 <a href=
"#id-eol-handling">End-of-Line Handling</a><br />
            A.2.3.1
<a href="#id-xml10-eol-handling">XML 1.0 End-of-Line
Handling</a><br />
            A.2.3.2
<a href="#id-xml11-eol-handling">XML 1.1 End-of-Line
Handling</a><br />
        A.2.4 <a href=
"#whitespace-rules">Whitespace Rules</a><br />
            A.2.4.1
<a href="#DefaultWhitespaceHandling">Default Whitespace
Handling</a><br />
            A.2.4.2
<a href="#ExplicitWhitespaceHandling">Explicit Whitespace
Handling</a><br />
    A.3 <a href=
"#id-reserved-fn-names">Reserved Function Names</a><br />
    A.4 <a href=
"#id-precedence-order">Precedence Order</a><br />
B <a href="#id-type-promotion-and-operator-mapping">Type Promotion
and Operator Mapping</a><br />
    B.1 <a href="#promotion">Type
Promotion</a><br />
    B.2 <a href="#mapping">Operator
Mapping</a><br />
C <a href="#id-xp-context-components">Context Components</a><br />
    C.1 <a href=
"#id-xp-static-context-components">Static Context
Components</a><br />
    C.2 <a href=
"#id-xp-evaluation-context-components">Dynamic Context
Components</a><br />
D <a href="#id-impl-defined-items">Implementation-Defined
Items</a><br />
E <a href="#id-references">References</a><br />
    E.1 <a href=
"#id-normative-references">Normative References</a><br />
    E.2 <a href=
"#id-non-normative-references">Non-normative References</a><br />
    E.3 <a href=
"#id-background-material">Background Material</a><br />
F <a href="#id-xpath-conformance">Conformance</a><br />
    F.1 <a href=
"#id-xpath-static-typing">Static Typing Feature</a><br />
        F.1.1 <a href=
"#id-xpath-static-extensions">Static Typing Extensions</a><br />
G <a href="#id-errors">Error Conditions</a><br />
H <a href="#id-glossary">Glossary</a> (Non-Normative)<br />
I <a href="#id-backwards-compatibility">Backwards Compatibility
with XPath 1.0</a> (Non-Normative)<br />
    I.1 <a href=
"#id-incompat-in-true-mode">Incompatibilities when Compatibility
Mode is true</a><br />
    I.2 <a href=
"#id-incompat-in-false-mode">Incompatibilities when Compatibility
Mode is false</a><br />
    I.3 <a href=
"#id-incompat-when-using-schema">Incompatibilities when using a
Schema</a><br />
J <a href="#id-revisions-log">Revision Log</a>
(Non-Normative)<br /></p>
</div>
<hr />
<div class="body">
<div class="div1">
<h2><a id="id-introduction" name="id-introduction"></a>1
Introduction</h2>
<div class="xpath">
<p class="xpath">The primary purpose of XPath is to address the
nodes of <a href="#XML">[XML 1.0]</a> or <a href="#XML1.1">[XML
1.1]</a> trees. XPath gets its name from its use of a path notation
for navigating through the hierarchical structure of an XML
document. XPath uses a compact, non-XML syntax to facilitate use of
XPath within URIs and XML attribute values.</p>
</div>
<p>[<a title="data model" id="dt-datamodel" name=
"dt-datamodel">Definition</a>: XPath operates on the abstract,
logical structure of an XML document, rather than its surface
syntax. This logical structure, known as the <b>data model</b>, is
defined in <a href="#datamodel">[XQuery/XPath Data Model
(XDM)]</a>.]</p>
<div class="xpath">
<p class="xpath">XPath is designed to be embedded in a <b>host
language</b> such as <a href="#XSLT">[XSLT 2.0]</a> or <a href=
"#xquery">[XQuery]</a>. XPath has a natural subset that can be used
for matching (testing whether or not a node matches a pattern);
this use of XPath is described in <a href="#XSLT">[XSLT
2.0]</a>.</p>
</div>
<p>XQuery Version 1.0 is an extension of XPath Version 2.0. Any
expression that is syntactically valid and executes successfully in
both XPath 2.0 and XQuery 1.0 will return the same result in both
languages. Since these languages are so closely related, their
grammars and language descriptions are generated from a common
source to ensure consistency, and the editors of these
specifications work together closely.</p>
<p>XPath also depends on and is closely related to the following
specifications:</p>
<ul>
<li>
<p><a href="#datamodel">[XQuery/XPath Data Model (XDM)]</a> defines
the data model that underlies all XPath expressions.</p>
</li>
<li>
<p><a href="#XQueryFormalSemantics">[XQuery 1.0 and XPath 2.0
Formal Semantics]</a> defines the static semantics of XPath and
also contains a formal but non-normative description of the dynamic
semantics that may be useful for implementors and others who
require a formal definition.</p>
</li>
<li>
<p>The type system of XPath is based on <a href="#XMLSchema">[XML
Schema]</a>.</p>
</li>
<li>
<p>The built-in function library and the operators supported by
XPath are defined in <a href="#FunctionsAndOperators">[XQuery 1.0
and XPath 2.0 Functions and Operators]</a>.</p>
</li>
</ul>
<p>This document specifies a grammar for XPath, using the same
basic EBNF notation used in <a href="#XML">[XML 1.0]</a>. Unless
otherwise noted (see <a href="#lexical-structure"><b>A.2 Lexical
structure</b></a>), whitespace is not significant in <span class=
"xpath"><span class="xpath">expressions</span></span>. Grammar
productions are introduced together with the features that they
describe, and a complete grammar is also presented in the appendix
[<a href="#nt-bnf"><b>A XPath Grammar</b></a>]. The appendix is the
normative version.</p>
<p>In the grammar productions in this document, named symbols are
underlined and literal text is enclosed in double quotes. For
example, the following production describes the syntax of a
function call:</p>
<table summary="Scrap" class="scrap">
<tbody>
<tr valign="baseline">
<td><a id="fakeid_doc-xpath-FunctionCall" name=
"fakeid_doc-xpath-FunctionCall"></a>[48]   </td>
<td><code>FunctionCall</code></td>
<td>   ::=   </td>
<td><code><a href="#prod-xpath-QName">QName</a> "(" (<a href=
"#doc-xpath-ExprSingle">ExprSingle</a> ("," <a href=
"#doc-xpath-ExprSingle">ExprSingle</a>)*)? ")"</code></td>
</tr>
</tbody>
</table>
<p>The production should be read as follows: A function call
consists of a QName followed by an open-parenthesis. The
open-parenthesis is followed by an optional argument list. The
argument list (if present) consists of one or more expressions,
separated by commas. The optional argument list is followed by a
close-parenthesis.</p>
<p>Certain aspects of language processing are described in this
specification as <b>implementation-defined</b> or
<b>implementation-dependent</b>.</p>
<ul>
<li>
<p>[<a title="implementation defined" id=
"dt-implementation-defined" name=
"dt-implementation-defined">Definition</a>:
<b>Implementation-defined</b> indicates an aspect that may differ
between implementations, but must be specified by the implementor
for each particular implementation.]</p>
</li>
<li>
<p>[<a title="implementation dependent" id=
"dt-implementation-dependent" name=
"dt-implementation-dependent">Definition</a>:
<b>Implementation-dependent</b> indicates an aspect that may differ
between implementations, is not specified by this or any W3C
specification, and is not required to be specified by the
implementor for any particular implementation.]</p>
</li>
</ul>
<div class="xpath">
<p class="xpath">A language aspect described in this specification
as <b>implementation-defined</b> or <b>implementation dependent</b>
may be further constrained by the specifications of a host language
in which XPath is embedded.</p>
</div>
<p>This document normatively defines the dynamic semantics of
XPath. The static semantics of XPath are normatively defined in
<a href="#XQueryFormalSemantics">[XQuery 1.0 and XPath 2.0 Formal
Semantics]</a>. In this document, examples and material labeled as
"Note" are provided for explanatory purposes and are not
normative.</p>
</div>
<div class="div1">
<h2><a id="id-basics" name="id-basics"></a>2 Basics</h2>
<p>The basic building block of XPath is the <b>expression</b>,
which is a string of <a href="#Unicode">[Unicode]</a> characters
(the version of Unicode to be used is <a title=
"implementation defined" href=
"#dt-implementation-defined">implementation-defined</a>.) The
language provides several kinds of expressions which may be
constructed from keywords, symbols, and operands. In general, the
operands of an expression are other expressions. XPath allows
expressions to be nested with full generality.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>This specification contains no assumptions or requirements
regarding the character set encoding of strings of <a href=
"#Unicode">[Unicode]</a> characters.</p>
</div>
<p>Like XML, XPath is a case-sensitive language. Keywords in XPath
use lower-case characters and are not reserved—that is, names in
XPath expressions are allowed to be the same as language keywords,
except for certain unprefixed function-names listed in <a href=
"#id-reserved-fn-names"><b>A.3 Reserved Function Names</b></a>.</p>
<p>[<a title="value" id="dt-value" name="dt-value">Definition</a>:
In the <a title="data model" href="#dt-datamodel">data model</a>, a
<b>value</b> is always a <a title="sequence" href=
"#dt-sequence">sequence</a>.] [<a title="sequence" id="dt-sequence"
name="dt-sequence">Definition</a>: A <b>sequence</b> is an ordered
collection of zero or more <a title="item" href=
"#dt-item">items</a>.] [<a title="item" id="dt-item" name=
"dt-item">Definition</a>: An <b>item</b> is either an <a title=
"atomic value" href="#dt-atomic-value">atomic value</a> or a
<a title="node" href="#dt-node">node</a>.] [<a title="atomic value"
id="dt-atomic-value" name="dt-atomic-value">Definition</a>: An
<b>atomic value</b> is a value in the value space of an <b>atomic
type</b>, as defined in <a href="#XMLSchema">[XML Schema]</a>.]
[<a title="node" id="dt-node" name="dt-node">Definition</a>: A
<b>node</b> is an instance of one of the <b>node kinds</b> defined
in <a href="#datamodel">[XQuery/XPath Data Model (XDM)]</a>.] Each
node has a unique <b>node identity</b>, a <b>typed value</b>, and a
<b>string value</b>. In addition, some nodes have a <b>name</b>.
The <b>typed value</b> of a node is a sequence of zero or more
atomic values. The <b>string value</b> of a node is a value of type
<code>xs:string</code>. The <b>name</b> of a node is a value of
type <code>xs:QName</code>.</p>
<p>[<a title="singleton" id="dt-singleton" name=
"dt-singleton">Definition</a>: A sequence containing exactly one
item is called a <b>singleton</b>.] An item is identical to a
singleton sequence containing that item. Sequences are never
nested—for example, combining the values 1, (2, 3), and ( ) into a
single sequence results in the sequence (1, 2, 3). [<a title=
"empty sequence" id="dt-empty-sequence" name=
"dt-empty-sequence">Definition</a>: A sequence containing zero
items is called an <b>empty sequence</b>.]</p>
<p>[<a title="XDM instance" id="dt-data-model-instance" name=
"dt-data-model-instance">Definition</a>: The term <b>XDM
instance</b> is used, synonymously with the term <b>value</b>, to
denote an unconstrained sequence of <a title="node" href=
"#dt-node">nodes</a> and/or <a title="atomic value" href=
"#dt-atomic-value">atomic values</a> in the <a title="data model"
href="#dt-datamodel">data model</a>.]</p>
<p>Names in XPath are called <b>QNames</b>, and conform to the
syntax in <a href="#XMLNAMES">[XML Names]</a>. [<a title="QName"
id="dt-qname" name="dt-qname">Definition</a>: Lexically, a
<b>QName</b> consists of an optional namespace prefix and a local
name. If the namespace prefix is present, it is separated from the
local name by a colon.] A lexical QName can be converted into an
<b>expanded QName</b> by resolving its namespace prefix to a
namespace URI, using the <a title="statically known namespaces"
href="#dt-static-namespaces">statically known namespaces</a>
[<a title="err:XPST0081" href="#ERRXPST0081">err:XPST0081</a>].
[<a title="expanded QName" id="dt-expanded-qname" name=
"dt-expanded-qname">Definition</a>: An <b>expanded QName</b>
consists of an optional namespace URI and a local name. An expanded
QName also retains its original namespace prefix (if any), to
facilitate casting the expanded QName into a string.] The namespace
URI value is whitespace normalized according to the rules for the
<code>xs:anyURI</code> type in <a href="#XMLSchema">[XML
Schema]</a>. Two expanded QNames are equal if their namespace URIs
are equal and their local names are equal (even if their namespace
prefixes are not equal). Namespace URIs and local names are
compared on a codepoint basis, without further normalization.</p>
<p><span class="xpath"><span class="xpath">This document uses the
following namespace prefixes to represent the namespace URIs with
which they are listed. Use of these namespace prefix bindings in
this document is not normative.</span></span></p>
<ul>
<li>
<p><code>xs = http://www.w3.org/2001/XMLSchema</code></p>
</li>
<li>
<p><code>fn = http://www.w3.org/2005/xpath-functions</code></p>
</li>
<li class="xpath">
<p><code>err = http://www.w3.org/2005/xqt-errors</code> (see
<a href="#id-identifying-errors"><b>2.3.2 Identifying and Reporting
Errors</b></a>).</p>
</li>
</ul>
<p>Element nodes have a property called <b>in-scope namespaces</b>.
[<a title="in-scope namespaces" id="dt-in-scope-namespaces" name=
"dt-in-scope-namespaces">Definition</a>: The <b>in-scope
namespaces</b> property of an element node is a set of <b>namespace
bindings</b>, each of which associates a namespace prefix with a
URI, thus defining the set of namespace prefixes that are available
for interpreting QNames within the scope of the element. For a
given element, one namespace binding may have an empty prefix; the
URI of this namespace binding is the default namespace within the
scope of the element.]</p>
<div class="xpath">
<p class="xpath">In <a href="#XPath">[XPath 1.0]</a>, the in-scope
namespaces of an element node are represented by a collection of
<b>namespace nodes</b> arranged on a <b>namespace axis</b>. In
XPath Version 2.0, the namespace axis is deprecated and need not be
supported by a host language. A host language that does not support
the namespace axis need not represent namespace bindings in the
form of nodes.</p>
</div>
<p>[<a title="URI" id="dt-URI" name="dt-URI">Definition</a>: Within
this specification, the term <b>URI</b> refers to a Universal
Resource Identifier as defined in <a href="#RFC3986">[RFC3986]</a>
and extended in <a href="#RFC3987">[RFC3987]</a> with the new name
<b>IRI</b>.] The term URI has been retained in preference to IRI to
avoid introducing new names for concepts such as "Base URI" that
are defined or referenced across the whole family of XML
specifications.</p>
<div class="div2">
<h3><a id="context" name="context"></a>2.1 Expression Context</h3>
<p>[<a title="expression context" id="dt-expression-context" name=
"dt-expression-context">Definition</a>: The <b>expression
context</b> for a given expression consists of all the information
that can affect the result of the expression.] This information is
organized into two categories called the <a title="static context"
href="#dt-static-context">static context</a> and the <a title=
"dynamic context" href="#dt-dynamic-context">dynamic
context</a>.</p>
<div class="div3">
<h4><a id="static_context" name="static_context"></a>2.1.1 Static
Context</h4>
<p>[<a title="static context" id="dt-static-context" name=
"dt-static-context">Definition</a>: The <b>static context</b> of an
expression is the information that is available during static
analysis of the expression, prior to its evaluation.] This
information can be used to decide whether the expression contains a
<a title="static error" href="#dt-static-error">static error</a>.
If analysis of an expression relies on some component of the
<a title="static context" href="#dt-static-context">static
context</a> that has not been assigned a value, a <a title=
"static error" href="#dt-static-error">static error</a> is raised
[<a title="err:XPST0001" href="#ERRXPST0001">err:XPST0001</a>].</p>
<p>The individual components of the <a title="static context" href=
"#dt-static-context">static context</a> are summarized below.
<span class="xpath"><span class="xpath">A default initial value for
each component may be specified by the host language. The scope of
each component is specified in <a href=
"#id-xp-static-context-components"><b>C.1 Static Context
Components</b></a>.</span></span></p>
<ul>
<li>
<p>[<a title="XPath 1.0 compatibility mode" id=
"dt-xpath-compat-mode" name="dt-xpath-compat-mode">Definition</a>:
<b>XPath 1.0 compatibility mode.</b> <span class=
"xpath"><span class="xpath">This value is <code>true</code> if
rules for backward compatibility with XPath Version 1.0 are in
effect; otherwise it is <code>false</code>.</span></span>]</p>
</li>
<li>
<p>[<a title="statically known namespaces" id=
"dt-static-namespaces" name="dt-static-namespaces">Definition</a>:
<b>Statically known namespaces.</b> This is a set of (prefix, URI)
pairs that define all the namespaces that are known during static
processing of a given expression.] The URI value is whitespace
normalized according to the rules for the <code>xs:anyURI</code>
type in <a href="#XMLSchema">[XML Schema]</a>. Note the difference
between <a title="in-scope namespaces" href=
"#dt-in-scope-namespaces">in-scope namespaces</a>, which is a
dynamic property of an element node, and <a title=
"statically known namespaces" href=
"#dt-static-namespaces">statically known namespaces</a>, which is a
static property of an expression.</p>
</li>
<li>
<p>[<a title="default element/type namespace" id=
"dt-def-elemtype-ns" name="dt-def-elemtype-ns">Definition</a>:
<b>Default element/type namespace.</b> This is a namespace URI or
"none". The namespace URI, if present, is used for any unprefixed
QName appearing in a position where an element or type name is
expected.] The URI value is whitespace normalized according to the
rules for the <code>xs:anyURI</code> type in <a href=
"#XMLSchema">[XML Schema]</a>.</p>
</li>
<li>
<p>[<a title="default function namespace" id="dt-def-fn-ns" name=
"dt-def-fn-ns">Definition</a>: <b>Default function namespace.</b>
This is a namespace URI or "none". The namespace URI, if present,
is used for any unprefixed QName appearing in a position where a
function name is expected.] The URI value is whitespace normalized
according to the rules for the <code>xs:anyURI</code> type in
<a href="#XMLSchema">[XML Schema]</a>.</p>
</li>
<li>
<p>[<a title="in-scope schema definitions" id="dt-issd" name=
"dt-issd">Definition</a>: <b>In-scope schema definitions.</b> This
is a generic term for all the element declarations, attribute
declarations, and schema type definitions that are in scope during
processing of an expression.] It includes the following three
parts:</p>
<ul>
<li>
<p>[<a title="in-scope schema type" id="dt-is-types" name=
"dt-is-types">Definition</a>: <b>In-scope schema types.</b> Each
schema type definition is identified either by an <a title=
"expanded QName" href="#dt-expanded-qname">expanded QName</a> (for
a <b>named type</b>) or by an <a title="implementation dependent"
href="#dt-implementation-dependent">implementation-dependent</a>
type identifier (for an <b>anonymous type</b>). The in-scope schema
types include the predefined schema types described in <a href=
"#id-predefined-types"><b>2.5.1 Predefined Schema Types</b></a>.
]</p>
</li>
<li>
<p>[<a title="in-scope element declarations" id="dt-is-elems" name=
"dt-is-elems">Definition</a>: <b>In-scope element declarations.</b>
Each element declaration is identified either by an <a title=
"expanded QName" href="#dt-expanded-qname">expanded QName</a> (for
a top-level element declaration) or by an <a title=
"implementation dependent" href=
"#dt-implementation-dependent">implementation-dependent</a> element
identifier (for a local element declaration). ] An element
declaration includes information about the element's <a title=
"substitution group" href="#dt-substitution-group">substitution
group</a> affiliation.</p>
<p>[<a title="substitution group" id="dt-substitution-group" name=
"dt-substitution-group">Definition</a>: <b>Substitution groups</b>
are defined in <a href="#XMLSchema">[XML Schema]</a> Part 1,
Section 2.2.2.2. Informally, the substitution group headed by a
given element (called the <b>head element</b>) consists of the set
of elements that can be substituted for the head element without
affecting the outcome of schema validation.]</p>
</li>
<li>
<p>[<a title="in-scope attribute declarations" id="dt-is-attrs"
name="dt-is-attrs">Definition</a>: <b>In-scope attribute
declarations.</b> Each attribute declaration is identified either
by an <a title="expanded QName" href="#dt-expanded-qname">expanded
QName</a> (for a top-level attribute declaration) or by an
<a title="implementation dependent" href=
"#dt-implementation-dependent">implementation-dependent</a>
attribute identifier (for a local attribute declaration). ]</p>
</li>
</ul>
</li>
<li>
<p>[<a title="in-scope variables" id="dt-in-scope-variables" name=
"dt-in-scope-variables">Definition</a>: <b>In-scope variables.</b>
This is a set of (expanded QName, type) pairs. It defines the set
of variables that are available for reference within an expression.
The <a title="expanded QName" href="#dt-expanded-qname">expanded
QName</a> is the name of the variable, and the type is the
<a title="static type" href="#dt-static-type">static type</a> of
the variable.]</p>
<p>An expression that binds a variable (such as a <code>for</code>,
<code>some</code>, or <code>every</code> expression) extends the
<a title="in-scope variables" href=
"#dt-in-scope-variables">in-scope variables</a> of its
subexpressions with the new bound variable and its type.</p>
</li>
<li>
<p>[<a title="context item static type" id=
"dt-context-item-static-type" name=
"dt-context-item-static-type">Definition</a>: <b>Context item
static type.</b> This component defines the <a title="static type"
href="#dt-static-type">static type</a> of the context item within
the scope of a given expression.]</p>
</li>
<li>
<p>[<a title="function signature" id="dt-function-signature" name=
"dt-function-signature">Definition</a>: <b>Function signatures.</b>
This component defines the set of functions that are available to
be called from within an expression. Each function is uniquely
identified by its <a title="expanded QName" href=
"#dt-expanded-qname">expanded QName</a> and its arity (number of
parameters).] In addition to the name and arity, each function
signature specifies the <a title="static type" href=
"#dt-static-type">static types</a> of the function parameters and
result.</p>
<p>The <a title="function signature" href=
"#dt-function-signature">function signatures</a> include the
signatures of <a title="constructor function" href=
"#dt-constructor-function">constructor functions</a>, which are
discussed in <a href="#id-constructor-functions"><b>3.10.4
Constructor Functions</b></a>.</p>
</li>
<li>
<p>[<a title="statically known collations" id=
"dt-static-collations" name="dt-static-collations">Definition</a>:
<b>Statically known collations.</b> This is an <a title=
"implementation defined" href=
"#dt-implementation-defined">implementation-defined</a> set of
(URI, collation) pairs. It defines the names of the collations that
are available for use in processing expressions.] [<a title=
"collation" id="dt-collation" name="dt-collation">Definition</a>: A
<b>collation</b> is a specification of the manner in which strings
and URIs are compared and, by extension, ordered. For a more
complete definition of collation, see <a href=
"#FunctionsAndOperators">[XQuery 1.0 and XPath 2.0 Functions and
Operators]</a>.]</p>
</li>
<li>
<p>[<a title="default collation" id="dt-def-collation" name=
"dt-def-collation">Definition</a>: <b>Default collation.</b> This
identifies one of the collations in <a title=
"statically known collations" href=
"#dt-static-collations">statically known collations</a> as the
collation to be used by functions and operators for comparing and
ordering values of type <code>xs:string</code> and
<code>xs:anyURI</code> (and types derived from them) when no
explicit collation is specified.]</p>
</li>
<li>
<p>[<a title="base URI" id="dt-base-uri" name=
"dt-base-uri">Definition</a>: <b>Base URI.</b> This is an absolute
URI, used when necessary in the resolution of relative URIs (for
example, by the <code>fn:resolve-uri</code> function.)] The URI
value is whitespace normalized according to the rules for the
<code>xs:anyURI</code> type in <a href="#XMLSchema">[XML
Schema]</a>.</p>
</li>
<li>
<p>[<a title="statically known documents" id="dt-known-docs" name=
"dt-known-docs">Definition</a>: <b>Statically known documents.</b>
This is a mapping from strings onto types. The string represents
the absolute URI of a resource that is potentially available using
the <code>fn:doc</code> function. The type is the <a title=
"static type" href="#dt-static-type">static type</a> of a call to
<code>fn:doc</code> with the given URI as its literal argument. ]
If the argument to <code>fn:doc</code> is a string literal that is
not present in <b>statically known documents</b>, then the
<a title="static type" href="#dt-static-type">static type</a> of
<code>fn:doc</code> is <code>document-node()?</code>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>The purpose of the <b>statically known documents</b> is to
provide static type information, not to determine which documents
are available. A URI need not be found in the <b>statically known
documents</b> to be accessed using <code>fn:doc</code>.</p>
</div>
</li>
<li>
<p>[<a title="statically known collections" id=
"dt-known-collections" name="dt-known-collections">Definition</a>:
<b>Statically known collections.</b> This is a mapping from strings
onto types. The string represents the absolute URI of a resource
that is potentially available using the <code>fn:collection</code>
function. The type is the type of the sequence of nodes that would
result from calling the <code>fn:collection</code> function with
this URI as its argument.] If the argument to
<code>fn:collection</code> is a string literal that is not present
in <b>statically known collections</b>, then the <a title=
"static type" href="#dt-static-type">static type</a> of
<code>fn:collection</code> is <code>node()*</code>.</p>
<div class="note">
<p class="prefix"><b>Note:</b></p>
<p>The purpose of the <b>statically known collections</b> is to
provide static type information, not to determine which collections
are available. A URI need not be found in the <b>statically known
collections</b> to be accessed using
<code>fn:collection</code>.</p>
</div>
</li>
<li>
<p>[<a title="statically known default collection type" id=
"dt-known-default-collection" name=
"dt-known-default-collection">Definition</a>: <b>Statically known
default collection type.</b> This is the type of the sequence of
nodes that would result from calling the <code>fn:collection</code>
function with no arguments.] Unless initialized to some other value
by an implementation, the value of <b>statically known default
collection type</b> is <code>node()*</code>.</p>
</li>
</ul>
</div>
<div class="div3">
<h4><a id="eval_context" name="eval_context"></a>2.1.2 Dynamic
Context</h4>
<p>[<a title="dynamic context" id="dt-dynamic-context" name=
"dt-dynamic-context">Definition</a>: The <b>dynamic context</b> of
an expression is defined as information that is available at the
time the expression is evaluated.] If evaluation of an expression
relies on some part of the <a title="dynamic context" href=
"#dt-dynamic-context">dynamic context</a> that has not been
assigned a value, a <a title="dynamic error" href=
"#dt-dynamic-error">dynamic error</a> is raised [<a title=
"err:XPDY0002" href="#ERRXPDY0002">err:XPDY0002</a>].</p>
<p>The individual components of the <a title="dynamic context"
href="#dt-dynamic-context">dynamic context</a> are summarized
below. Further rules governing the semantics of these components
can be found in <a href=
"#id-xp-evaluation-context-components"><b>C.2 Dynamic Context
Components</b></a>.</p>
<p>The <a title="dynamic context" href=
"#dt-dynamic-context">dynamic context</a> consists of all the
components of the <a title="static context" href=
"#dt-static-context">static context</a>, and the additional
components listed below.</p>
<p>[<a title="focus" id="dt-focus" name="dt-focus">Definition</a>:
The first three components of the <a title="dynamic context" href=
"#dt-dynamic-context">dynamic context</a> (context item, context
position, and context size) are called the <b>focus</b> of the
expression. ] The focus enables the processor to keep track of
which items are being processed by the expression.</p>
<p>Certain language constructs, notably the <a title=
"path expression" href="#dt-path-expression">path expression</a>
<code>E1/E2</code> and the <a title="predicate" href=
"#dt-predicate">predicate</a> <code>E1[E2]</code>, create a new
focus for the evaluation of a sub-expression. In these constructs,
<code>E2</code> is evaluated once for each item in the sequence
that results from evaluating <code>E1</code>. Each time
<code>E2</code> is evaluated, it is evaluated with a different
focus. The focus for evaluating <code>E2</code> is referred to
below as the <b>inner focus</b>, while the focus for evaluating
<code>E1</code> is referred to as the <b>outer focus</b>. The inner
focus exists only while <code>E2</code> is being evaluated. When
this evaluation is complete, evaluation of the containing
expression continues with its original focus unchanged.</p>
<ul>
<li>
<p>[<a title="context item" id="dt-context-item" name=
"dt-context-item">Definition</a>: The <b>context item</b> is the
item currently being processed. An item is either an atomic value
or a node.][<a title="context node" id="dt-context-node" name=
"dt-context-node">Definition</a>: When the context item is a node,
it can also be referred to as the <b>context node</b>.] The context
item is returned by an expression consisting of a single dot