Вы находитесь на странице: 1из 2

node ( )

Simple Expressions Testing Path Expressions processing-instruction ( NCName )


$VarName Test if the condition is satisfied for at least one / Top level, document root processing-instruction ( StringLiteral )
( Expr ) combination of the bound expressions: / Step At top level processing-instruction ( )
() some VariableBinding , ... satisfies Expr Step Relative to current node schema-attribute ( AttributeName )
. (one dot: self) Test if the condition is satisfied for all of the // Step Anywhere within document schema-element ( ElementName )
QName ( Expr , ... ) bound expressions: Path / Step Immediately within Path text ( )
every VariableBinding , ... satisfies Expr Path // Step Anywhere within Path
QName ( )
Names and Types
IntegerLiteral Select one or the other of two possibiliites: Where a Step is one of:
XML QNames, with or without a colon-separated
DecimalLiteral if ( Expr ) then Expr else Expr Expr prefix, is use for all of:
DoubleLiteral AxisName::NameTest VarName
Either or both of two tests:
StringLiteral AxisName::KindTest AttributeName
Expr or Expr Expr and Expr
@NameTest (attribute test) ElementName
Test if they are the same node: NameTest (child element test) TypeName
Arithmetic Expressions Expr is Expr KindTest (child node test) AtomicType
+ Expr Expr + Expr Test if a node appears before or after another: .. (two dots: parent test) A SequenceType is one of:
- Expr Expr - Expr Expr << Expr Expr >> Expr Followed by zero or more predicates: empty-sequence ( )
Expr * Expr Expr div Expr [ Expr ] KindTest
Test an expression’s dynamic type: item ( )
Expr idiv Expr Expr mod Expr Where an AxisName is one of:
Expr instance of SequenceType AtomicType
ancestor ancestor-or-self
Test if an expression can be converted to a type: attribute child Where KindTest, item() or AtomicType can be
Creating Sequences optionally followed by:
Expr castable as AtomicType descendant descendant-or-self
Create a sequence from a list of items: Expr castable as AtomicType? following following-sibling ? (may be empty sequence)\
Expr , ... namespace parent + (is a non-empty sequence of the type)
Note: A sequence list must usually be parenthesized. Compare two atomic values: * (is a sequence of the type, empty or
preceding preceding-sibling
Expr eq Expr Expr ne Expr self not)
Repeat over one or more sequences, returning a
sequence of results: Expr lt Expr Expr le Expr
Where a NameTest is one of:
Expr gt Expr Expr ge Expr QName
Operator Precedence:
for VariableBinding , ... return Expr
Compare all items in one sequence to all items in * 1 , (comma)
where a VariableBinding is:
a second, and return if true for any pair of values: NCName:* 2 for some every if
$VarName in Expr *:NCName
Expr = Expr Expr != Expr 3 or
Create a numeric sequences, from lower bound to Expr < Expr Expr <= Expr Where a KindTest is one of: 4 and
upper bound: 5 = != < <= > >=
Expr > Expr Expr >= Expr attribute ( AttributeName )
Expr to Expr eq ne lt le gt ge is << >>
attribute ( AttributeName , TypeName )
6 to
All the items appearing in either sequence: attribute ( * )
Type Modification Expressions 7 (two-argument) + -
Expr union Expr attribute ( * , TypeName )
Use as without converting: 8 * div idiv mod
Expr | Expr attribute ( )
Expr treat as SequenceType 9 union |
comment ( )
Only items appearing in both sequences: 10 intersect except
Use as, converting as needed and doable: document-node ( element ... )
Expr intersect Expr 11 instance of
Expr cast as AtomicType document-node ( schema-element ... )
All items in the first sequence not in second: Expr cast as AtomicType? 12 treat as
document-node ( )
Expr except Expr 13 castable as
element ( ElementName )
14 cast as
element ( ElementName , TypeName )
XPath 2.0: 15 (one-argument) + -
Comments in XPath Expressions http://www.w3.org/TR/xpath20/ element ( * )
16 / //
XSL-List: element ( * , TypeName )
(: This is a comment within an XPath expr :) 17 step node-test $name
http://www.mulberrytech.com/xsl/xsl-list element ( )
( Expr ) function-call literal
step except *[1]
Relative Location Paths step element children but the first Absolute Location Paths
Relative Location Paths traverse the document step[position() le 4] Absolute Location Paths traverse the document
from the context node the first four step element children starting at the top (the root), and can be
para
para element children
Also - step[position() = (1 to 4)]
step[position() mod 2]
XPath 2.0 recognized by their initial / (forwardslash).
/book/bookinfo/abstract

Quick Reference
Also - child::para odd-numbered step children an abstract element child of a bookinfo child
@type step[not(position() mod 2)] of the book document element
the type attribute even-numbered step children Also -
Also - attribute::type /child::book/child::bookinfo/child::abstract
*[position() le 4] intersect step
../title from the first four element children, the step //para
the title element children of the parent children See also the “XQuery 1.0 & XPath all para elements in the document
* except title ancestor-or-self::*[exists(@lang)][1]/@lang 2.0 Functions & Operators Quick Also - /descendant-or-self::*/child::para
child elements except title elements Also - /descendant::para
Also - *[not(self::title)] (works in XPath 1.0)
the closest lang attribute on the context node Reference”
or an ancestor element /descendant::para[1]
ancestor::sec the first para element in the document
all sec ancestor elements Expressions that are not Location Paths Also - (//para)[1]
ancestor::sec/@n (@class,'none')[1] //@order-by
all n attributes on sec ancestor elements the class attribute, or if it does not exist, the all order-by attributes in the document
list/(item | step) string "none".
item and step element children of list Also - //list[exists(ancestor::list)]
children, in document order if (exists(@class)) then @class else "none" all list elements that have ancestor
//*/name() listelements
list/item, list/step
the names of all elements, in document order //list[not(ancestor::list)]
item element children of list children followed
by step children of list children distinct-values(//*/name()) all list elements that do not have ancestor list
the names of all elements, in document order, elements
preceding-sibling::step Also - //list[not(exists(ancestor::list))]
all preceding sibling step elements with duplicates removed
Sam Wilmott Also - //list[empty(ancestor::list)]
preceding-sibling::*[1][self::step] //name/string-join((first, last),' ')
a sequence of strings constructed from the sam@wilmott.ca //(* except title)
the directly preceding sibling element, if it is a http://www.wilmott.ca
step (otherwise nothing) name elements in the document, each one all elements except title elements
concatenating the values of its first and last and Also - //*[not(self::title)] (works in XPath 1.0)
descendant::div[last()] element children, in that order, joining them
the last div descendant of the current node with spaces Mulberry Technologies, Inc. //processing-instruction()[not(ancestor::sec/@n = 1)]
Also - for $n in //name return 17 West Jefferson Street, Suite 207 all processing instructions with no sec ancestor
.//div[last()] elements with n attributes equal to 1
string-join(($n/first,$n/last),' ') Rockville, MD 20850 USA
div descendants that are the last child div of
//*/count(ancestor-or-self::*) Phone: +1 301/315-9631 //para[matches(.,'[X|x]{3}')]
each of their parents
a sequence of numbers representing the Fax: +1 301/315-8285 all para elements whose value includes the
preceding::pb[1] depth of each element in the document info@mulberrytech.com regular expression [X|x]{3}
the first (most immediate) preceding pb http://www.mulberrytech.com Tip - [X|x]{3} matches three X or xcharacters
max(//*/count(ancestor-or-self::*))
ancestor::sec//pb intersect preceding::pb appearing in a row
the maximum depth of all elements in the
pb elements inside the same sec element as
document (a number in a singleton sequence) //sec[@id = //@rid/tokenize(.,'\s+')]
the context node, preceding it
for $stooge in ('Moe','Larry','Curly') all sec elements with id attributes whose
p[normalize-space()] values are also given as a value by a
returncount(//p[contains(.,$stooge)])
p child elements that have a non-whitespace the counts of all p elements in the document tokenized rid attribute anywhere in the
value (text content) mentioning each of "Moe", "Larry" and "Curly", document
*[not(node())] in that order Also - //sec[@id = $rid-values] where
empty element children (i.e., element children $rid-values is
index-of(('Moe','Larry','Curly'), speaker[1]) distinct-values(//@rid/tokenize(.,'\s+'))
with no node children) if the first speaker element child has the value Tip - use
*[not(node() except (comment()| "Moe", then 1; if "Larry", then 2; if "Curly", distinct-values(//@rid/tokenize(.,'\s+')) to
processing-instruction())] then 3; otherwise the empty sequence (i.e., no remove duplicates from the list of tokenized
element children that are empty (have no value) @rid values
children) except for comments or processing (: You’ve got to be kidding me. :) Tip - the regular expression \s+ matches any
instructions
do nothing. A comment is just a comment.
© 2007-2008 Sam Wilmott and contiguous sequence of spaces (space,
step[position() gt 1] Mulberry Technologies, Inc. linefeed or tab characters)
all step element children but the first 2008-07-21

Вам также может понравиться