Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
71 views

Xpath Reference: by Keimoon

The document provides an overview of XPath including: 1. It describes the data model including different node types like element nodes, attribute nodes, and text nodes. 2. It explains location paths which are used to navigate through the XML document tree and select nodes, including axis names like child, descendant, and predicates. 3. It covers expressions which are used to extract or compute values from the XML document, and functions that can be used as part of expressions.

Uploaded by

openid_k9ZIjgLj
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

Xpath Reference: by Keimoon

The document provides an overview of XPath including: 1. It describes the data model including different node types like element nodes, attribute nodes, and text nodes. 2. It explains location paths which are used to navigate through the XML document tree and select nodes, including axis names like child, descendant, and predicates. 3. It covers expressions which are used to extract or compute values from the XML document, and functions that can be used as part of expressions.

Uploaded by

openid_k9ZIjgLj
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Xpath Reference

By KeiMOon
Table of contents

1. Data model
2. Location paths
3. Expressions
4. Core functions
Data model
 Node type
 Root node:
 string value = concatenation of all string value
 Element node
 string value = concatenation of all string value
 Attribute node
 string value = text
 has element node as its parent, but is not a child.
Data model
 Node type (cont)
 Namespace node
 string value is the URI
 Processing instruction node
 Comment node
 Text node
 Must be a child of a element node
 Will have no sibling
Location paths
 Location path
 LocationPath ::= RelativeLocationPath |
AbsoluteLocationPath
 AbsoluteLocationPath ::= '/' RelativeLocationPath? |
AbbreviatedAbsoluteLocationPath
 RelativeLocationPath ::= Step | RelativeLocationPath '/'
Step | AbbreviatedRelativeLocationPath
Location Paths
 Location step
 Step ::= AxisSpecifier NodeTest Predicate* |
AbbreviatedStep
 AxisSpecifier ::= AxisName '::’ |
AbbreviatedAxisSpecifier
Location paths
 Axis name
 AxisName ::= 'ancestor | 'ancestor-or-self’ | 'attribute’|
'child’ | 'descendant’ | 'descendant-or-self’ |
'following’ | 'following-sibling’ | 'namespace’ |
'parent’ | 'preceding’ | 'preceding-sibling’| 'self'
Location Paths
 Axis Name (cont)
 child : contains the children of the context node
 descendant : contains the descendants of the context
node
 parent : contains the parent of the context node
 ancestor : contains the ancestors of the context node
 following-sibling : contains all the following siblings of
the context node
 preceding-sibling : contains all the preceding siblings of
the context node
Location Paths
 Axis name (cont)
 following : contains all nodes in the same document as
the context node that are after the context node in
document order, excluding any descendants and
excluding attribute nodes and namespace nodes
 preceding : contains all nodes in the same document as
the context node that are before the context node in
document order, excluding any ancestors and excluding
attribute nodes and namespace nodes
Location Paths
 Axis name
 attribute : contains the attributes of the context node
 namespace : contains the namespace nodes of the
context node
 self : contains just the context node itself
 descendant-or-self : contains the context node and the
descendants of the context node
 ancestor-or-self : contains the context node and the
ancestors of the context node
Location Paths
 Node test
 NodeTest ::= NameTest | NodeType '(' ')’ |
'processing-instruction' '(' Literal ')'
Location paths
 Predicates
 Predicate ::=  '[' PredicateExpr ']'
 PredicateExpr ::= Expr
Location paths
 Abbreviations
 * selects all element children of the context node
 text() selects all text node children of the context node
 @name selects the name attribute of the context node
 // is short for /descendant-or-self::node()/
 . is short for self::node()
 .. is short for parent::node()
Expressions
 Basics
 Expr ::= OrExpr
 PrimaryExpr ::=  VariableReference | '(' Expr ')’ | Literal |
Number | FunctionCal

 Function calls
 FunctionCall ::= FunctionName '(' ( Argument ( ','
Argument )* )? ')'
 Argument ::=  Expr
Expressions
 Node sets
 UnionExpr ::= PathExpr | UnionExpr '|' PathExpr
 PathExpr ::= LocationPath | FilterExpr | FilterExpr '/’
RelativeLocationPath| FilterExpr '//' RelativeLocationPath

 FilterExpr ::= PrimaryExpr | FilterExpr Predicate

You might also like