<s>
XPath	B-Language
(	O
XML	B-Language
Path	I-Language
Language	I-Language
)	O
is	O
an	O
expression	O
language	O
designed	O
to	O
support	O
the	O
query	O
or	O
transformation	O
of	O
XML	B-Protocol
documents	I-Protocol
.	O
</s>
<s>
It	O
was	O
defined	O
by	O
the	O
World	O
Wide	O
Web	O
Consortium	O
(	O
W3C	O
)	O
and	O
can	O
be	O
used	O
to	O
compute	O
values	O
(	O
e.g.	O
,	O
strings	O
,	O
numbers	O
,	O
or	O
Boolean	O
values	O
)	O
from	O
the	O
content	O
of	O
an	O
XML	B-Protocol
document	I-Protocol
.	O
</s>
<s>
Support	O
for	O
XPath	B-Language
exists	O
in	O
applications	O
that	O
support	O
XML	B-Protocol
,	O
such	O
as	O
web	O
browsers	O
,	O
and	O
many	O
programming	O
languages	O
.	O
</s>
<s>
The	O
XPath	B-Language
language	O
is	O
based	O
on	O
a	O
tree	B-Language
representation	I-Language
of	I-Language
the	I-Language
XML	I-Language
document	I-Language
,	O
and	O
provides	O
the	O
ability	O
to	O
navigate	O
around	O
the	O
tree	O
,	O
selecting	O
nodes	O
by	O
a	O
variety	O
of	O
criteria	O
.	O
</s>
<s>
In	O
popular	O
use	O
(	O
though	O
not	O
in	O
the	O
official	O
specification	O
)	O
,	O
an	O
XPath	B-Language
expression	O
is	O
often	O
referred	O
to	O
simply	O
as	O
"	O
an	O
XPath	B-Language
"	O
.	O
</s>
<s>
Originally	O
motivated	O
by	O
a	O
desire	O
to	O
provide	O
a	O
common	O
syntax	O
and	O
behavior	O
model	O
between	O
XPointer	B-General_Concept
and	O
XSLT	B-Application
,	O
subsets	O
of	O
the	O
XPath	B-Language
query	B-Language
language	I-Language
are	O
used	O
in	O
other	O
W3C	O
specifications	O
such	O
as	O
XML	B-Protocol
Schema	O
,	O
XForms	B-Application
and	O
the	O
Internationalization	B-Language
Tag	I-Language
Set	I-Language
(	O
ITS	O
)	O
.	O
</s>
<s>
XPath	B-Language
has	O
been	O
adopted	O
by	O
a	O
number	O
of	O
XML	B-Protocol
processing	O
libraries	O
and	O
tools	O
,	O
many	O
of	O
which	O
also	O
offer	O
CSS	B-Language
Selectors	I-Language
,	O
another	O
W3C	O
standard	O
,	O
as	O
a	O
simpler	O
alternative	O
to	O
XPath	B-Language
.	O
</s>
<s>
There	O
are	O
several	O
versions	O
of	O
XPath	B-Language
in	O
use	O
.	O
</s>
<s>
XPath	B-Language
1.0	I-Language
was	O
published	O
in	O
1999	O
,	O
XPath	B-General_Concept
2.0	I-General_Concept
in	O
2007	O
(	O
with	O
a	O
second	O
edition	O
in	O
2010	O
)	O
,	O
XPath	B-General_Concept
3.0	I-General_Concept
in	O
2014	O
,	O
and	O
XPath	B-General_Concept
3.1	I-General_Concept
in	O
2017	O
.	O
</s>
<s>
However	O
,	O
XPath	B-Language
1.0	I-Language
is	O
still	O
the	O
version	O
that	O
is	O
most	O
widely	O
available	O
.	O
</s>
<s>
XPath	B-Language
1.0	I-Language
became	O
a	O
Recommendation	O
on	O
16	O
November	O
1999	O
and	O
is	O
widely	O
implemented	O
and	O
used	O
,	O
either	O
on	O
its	O
own	O
(	O
called	O
via	O
an	O
API	B-General_Concept
from	O
languages	O
such	O
as	O
Java	B-Language
,	O
C#	B-Application
,	O
Python	B-Language
or	O
JavaScript	B-Language
)	O
,	O
or	O
embedded	O
in	O
languages	O
such	O
as	O
XSLT	B-Application
,	O
XProc	B-Language
,	O
XML	B-Protocol
Schema	O
or	O
XForms	B-Application
.	O
</s>
<s>
XPath	B-General_Concept
2.0	I-General_Concept
became	O
a	O
Recommendation	O
on	O
23	O
January	O
2007	O
,	O
with	O
a	O
second	O
edition	O
published	O
on	O
14	O
December	O
2010	O
.	O
</s>
<s>
A	O
number	O
of	O
implementations	O
exist	O
but	O
are	O
not	O
as	O
widely	O
used	O
as	O
XPath	B-Language
1.0	I-Language
.	O
</s>
<s>
The	O
XPath	B-General_Concept
2.0	I-General_Concept
language	O
specification	O
is	O
much	O
larger	O
than	O
XPath	B-Language
1.0	I-Language
and	O
changes	O
some	O
of	O
the	O
fundamental	O
concepts	O
of	O
the	O
language	O
such	O
as	O
the	O
type	O
system	O
.	O
</s>
<s>
The	O
most	O
notable	O
change	O
is	O
that	O
XPath	B-General_Concept
2.0	I-General_Concept
is	O
built	O
around	O
the	O
XQuery	B-Application
and	I-Application
XPath	I-Application
Data	I-Application
Model	I-Application
(	O
XDM	B-Application
)	O
that	O
has	O
a	O
much	O
richer	O
type	O
system	O
.	O
</s>
<s>
XPath	B-Language
1.0	I-Language
node-sets	O
are	O
replaced	O
by	O
node	O
sequences	O
,	O
which	O
may	O
be	O
in	O
any	O
order	O
.	O
</s>
<s>
To	O
support	O
richer	O
type	O
sets	O
,	O
XPath	B-General_Concept
2.0	I-General_Concept
offers	O
a	O
greatly	O
expanded	O
set	O
of	O
functions	O
and	O
operators	O
.	O
</s>
<s>
XPath	B-General_Concept
2.0	I-General_Concept
is	O
in	O
fact	O
a	O
subset	O
of	O
XQuery	B-Language
1.0	O
.	O
</s>
<s>
They	O
share	O
the	O
same	O
data	O
model	O
(	O
XDM	B-Application
)	O
.	O
</s>
<s>
It	O
offers	O
a	O
for	O
expression	O
that	O
is	O
a	O
cut-down	O
version	O
of	O
the	O
"	O
FLWOR	B-Language
"	O
expressions	O
in	O
XQuery	B-Language
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
describe	O
the	O
language	O
by	O
listing	O
the	O
parts	O
of	O
XQuery	B-Language
that	O
it	O
leaves	O
out	O
:	O
the	O
main	O
examples	O
are	O
the	O
query	O
prolog	O
,	O
element	O
and	O
attribute	O
constructors	O
,	O
the	O
remainder	O
of	O
the	O
"	O
FLWOR	B-Language
"	O
syntax	O
,	O
and	O
the	O
typeswitch	O
expression	O
.	O
</s>
<s>
XPath	B-General_Concept
3.0	I-General_Concept
became	O
a	O
Recommendation	O
on	O
8	O
April	O
2014	O
.	O
</s>
<s>
XPath	B-General_Concept
3.0	I-General_Concept
is	O
a	O
subset	O
of	O
XQuery	B-Language
3.0	O
,	O
and	O
most	O
current	O
implementations	O
(	O
April	O
2014	O
)	O
exist	O
as	O
part	O
of	O
an	O
XQuery	B-Language
3.0	O
engine	O
.	O
</s>
<s>
XPath	B-General_Concept
3.1	I-General_Concept
became	O
a	O
Recommendation	O
on	O
21	O
March	O
2017	O
.	O
</s>
<s>
This	O
version	O
adds	O
new	O
data	O
types	O
:	O
maps	O
and	O
arrays	O
,	O
largely	O
to	O
underpin	O
support	O
for	O
JSON	B-General_Concept
.	O
</s>
<s>
The	O
most	O
important	O
kind	O
of	O
expression	O
in	O
XPath	B-Language
is	O
a	O
location	O
path	O
.	O
</s>
<s>
An	O
XPath	B-Language
expression	O
is	O
evaluated	O
with	O
respect	O
to	O
a	O
context	O
node	O
.	O
</s>
<s>
The	O
node	O
test	O
and	O
the	O
predicate	O
are	O
used	O
to	O
filter	B-Application
the	O
nodes	O
specified	O
by	O
the	O
axis	O
specifier	O
:	O
For	O
example	O
,	O
the	O
node	O
test	O
'	O
A	O
 '	O
requires	O
that	O
all	O
nodes	O
navigated	O
to	O
must	O
have	O
label	O
'	O
A	O
 '	O
.	O
</s>
<s>
A	O
predicate	O
can	O
be	O
used	O
to	O
specify	O
that	O
the	O
selected	O
nodes	O
have	O
certain	O
properties	O
,	O
which	O
are	O
specified	O
by	O
XPath	B-Language
expressions	O
themselves	O
.	O
</s>
<s>
The	O
XPath	B-Language
syntax	O
comes	O
in	O
two	O
flavors	O
:	O
the	O
abbreviated	O
syntax	O
,	O
is	O
more	O
compact	O
and	O
allows	O
XPaths	B-Language
to	O
be	O
written	O
and	O
read	O
easily	O
using	O
intuitive	O
and	O
,	O
in	O
many	O
cases	O
,	O
familiar	O
characters	O
and	O
constructs	O
.	O
</s>
<s>
that	O
selects	O
C	O
elements	O
that	O
are	O
children	O
of	O
B	O
elements	O
that	O
are	O
children	O
of	O
the	O
A	O
element	O
that	O
forms	O
the	O
outermost	O
element	O
of	O
the	O
XML	B-Protocol
document	I-Protocol
.	O
</s>
<s>
The	O
XPath	B-Language
syntax	O
is	O
designed	O
to	O
mimic	O
URI	B-Protocol
(	O
Uniform	B-Protocol
Resource	I-Protocol
Identifier	I-Protocol
)	O
and	O
Unix-style	O
file	O
path	O
syntax	O
.	O
</s>
<s>
Note	O
also	O
,	O
index	O
values	O
in	O
XPath	B-Language
predicates	O
(	O
technically	O
,	O
'	O
proximity	O
positions	O
 '	O
of	O
XPath	B-Language
node	O
sets	O
)	O
start	O
from	O
1	O
,	O
not	O
0	O
as	O
common	O
in	O
languages	O
like	O
C	O
and	O
Java	B-Language
.	O
</s>
<s>
Here	O
,	O
in	O
each	O
step	O
of	O
the	O
XPath	B-Language
,	O
the	O
axis	O
(	O
e.g.	O
</s>
<s>
Axis	O
specifiers	O
indicate	O
navigation	O
direction	O
within	O
the	O
tree	B-Language
representation	I-Language
of	I-Language
the	I-Language
XML	I-Language
document	I-Language
.	O
</s>
<s>
In	O
the	O
case	O
of	O
an	O
XML	B-Protocol
document	I-Protocol
in	O
which	O
the	O
namespace	O
prefix	O
gs	O
has	O
been	O
defined	O
,	O
//gs:enquiry	O
will	O
find	O
all	O
the	O
enquiry	O
elements	O
in	O
that	O
namespace	O
,	O
and	O
//gs	O
:	O
*	O
will	O
find	O
all	O
elements	O
,	O
regardless	O
of	O
local	O
name	O
,	O
in	O
that	O
namespace	O
.	O
</s>
<s>
finds	O
an	O
XML	B-Protocol
comment	O
node	O
,	O
e.g.	O
</s>
<s>
finds	O
XML	B-Protocol
processing	B-Language
instructions	I-Language
such	O
as	O
.	O
</s>
<s>
Predicates	O
,	O
written	O
as	O
expressions	O
in	O
square	O
brackets	O
,	O
can	O
be	O
used	O
to	O
filter	B-Application
a	O
node-set	O
according	O
to	O
some	O
condition	O
.	O
</s>
<s>
There	O
is	O
no	O
limit	O
to	O
the	O
number	O
of	O
predicates	O
in	O
a	O
step	O
,	O
and	O
they	O
need	O
not	O
be	O
confined	O
to	O
the	O
last	O
step	O
in	O
an	O
XPath	B-Language
.	O
</s>
<s>
XPath	B-Language
1.0	I-Language
defines	O
four	O
data	O
types	O
:	O
node-sets	O
(	O
sets	O
of	O
nodes	O
with	O
no	O
intrinsic	O
order	O
)	O
,	O
strings	O
,	O
numbers	O
and	O
booleans	O
.	O
</s>
<s>
returns	O
a	O
number	O
representing	O
the	O
position	O
of	O
this	O
node	O
in	O
the	O
sequence	O
of	O
nodes	O
currently	O
being	O
processed	O
(	O
for	O
example	O
,	O
the	O
nodes	O
selected	O
by	O
an	O
xsl:for-each	O
instruction	O
in	O
XSLT	B-Application
)	O
.	O
</s>
<s>
converts	O
any	O
of	O
the	O
four	O
XPath	B-Language
data	O
types	O
into	O
a	O
string	O
according	O
to	O
built-in	O
rules	O
.	O
</s>
<s>
This	O
is	O
very	O
useful	O
when	O
the	O
original	O
XML	B-Protocol
may	O
have	O
been	O
prettyprint	B-Application
formatted	O
,	O
which	O
could	O
make	O
further	O
string	O
processing	O
unreliable	O
.	O
</s>
<s>
converts	O
the	O
string	O
values	O
of	O
all	O
the	O
nodes	O
found	O
by	O
the	O
XPath	B-Language
argument	O
into	O
numbers	O
,	O
according	O
to	O
the	O
built-in	O
casting	O
rules	O
,	O
then	O
returns	O
the	O
sum	O
of	O
these	O
numbers	O
.	O
</s>
<s>
XMLStarlet	B-Application
easy	O
to	O
use	O
tool	O
to	O
test/execute	O
XPath	B-Language
commands	O
on	O
the	O
fly	O
.	O
</s>
<s>
Sedna	B-Application
XML	I-Application
Database	I-Application
Both	O
XML:DB	O
and	O
proprietary	O
.	O
</s>
<s>
package	O
has	O
been	O
part	O
of	O
Java	B-Language
standard	O
edition	O
since	O
Java	B-Language
5	O
via	O
the	O
Java	B-Language
API	I-Language
for	I-Language
XML	I-Language
Processing	I-Language
.	O
</s>
<s>
Technically	O
this	O
is	O
an	O
XPath	B-Language
API	B-General_Concept
rather	O
than	O
an	O
XPath	B-Language
implementation	O
,	O
and	O
it	O
allows	O
the	O
programmer	O
the	O
ability	O
to	O
select	O
a	O
specific	O
implementation	O
that	O
conforms	O
to	O
the	O
interface	O
.	O
</s>
<s>
Open	B-License
source	I-License
XPath	B-General_Concept
3.1	I-General_Concept
implementation	O
in	O
JavaScript	B-Language
.	O
</s>
<s>
XPath	B-Language
is	O
increasingly	O
used	O
to	O
express	O
constraints	O
in	O
schema	O
languages	O
for	O
XML	B-Protocol
.	O
</s>
<s>
The	O
(	O
now	O
ISO	O
standard	O
)	O
schema	O
language	O
Schematron	B-Language
pioneered	O
the	O
approach	O
.	O
</s>
<s>
A	O
streaming	B-Language
subset	O
of	O
XPath	B-Language
is	O
used	O
in	O
W3C	O
XML	B-Protocol
Schema	O
1.0	O
for	O
expressing	O
uniqueness	O
and	O
key	O
constraints	O
.	O
</s>
<s>
In	O
XSD	O
1.1	O
,	O
the	O
use	O
of	O
XPath	B-Language
is	O
extended	O
to	O
support	O
conditional	O
type	O
assignment	O
based	O
on	O
attribute	O
values	O
,	O
and	O
to	O
allow	O
arbitrary	O
boolean	O
assertions	O
to	O
be	O
evaluated	O
against	O
the	O
content	O
of	O
elements	O
.	O
</s>
<s>
XForms	B-Application
uses	O
XPath	B-Language
to	O
bind	O
types	O
to	O
values	O
.	O
</s>
<s>
The	O
approach	O
has	O
even	O
found	O
use	O
in	O
non-XML	O
applications	O
,	O
such	O
as	O
the	O
source	O
code	O
analyzer	O
for	O
Java	B-Language
called	O
PMD	B-Language
:	O
the	O
Java	B-Language
is	O
converted	O
to	O
a	O
DOM-like	O
parse	O
tree	O
,	O
then	O
XPath	B-Language
rules	O
are	O
defined	O
over	O
the	O
tree	O
.	O
</s>
