XPath(1) Overview of XPath

XPath1.0 is the language to access node-set in XML Document. XPath2.0 is the language to access Sequence instead.

Every value in XPath 2.0 is a sequence of items. The items may be nodes or atomic values.

xPath = Path Expression + Condition

Everything is Sequence

There is only one data type in XPath2.0 - Sequence
Sequence could be items 
items could be node-set or atomic value or both
Items count from 1, actually Xpath count from 1

Operators

Xpath has its own set of operators:

Operators Effect
+, -, *, div, mod, idivArithmetic on numbers, dates, and durations
=, !=, <, >, <=, >=General comparison: compare arbitrary sequences. The result is true if any pair of items, one from each sequence, satisfies the comparison
eq, ne, lt, gt, le, geValue comparison: compare single items
isCompare node identity: true if both operands are the same node
<<, >>Compare node position, based on document order
union, intersect, exceptCompare sequences of nodes, treating them as sets, returning the set union, intersection, or difference
and, orboolean conjunction and disjunction. Negation is achieved using the not() function.
todefines an integer range, for example 1 to 10
instance ofdetermines whether a value is an instance of a given type
cast asconverts a value to a given type
castable astests whether a value is convertible to a given type

table from wiki

Path Expression

The path expression is the primary use of xpath. Path expression is usually in the format ofaxis::node-test[predicate]


Function library

XPath contains a large number of functions for working with different data types.


Purpose Example Functions
General string handlinglower-case, upper-case, substringsubstring-beforesubstring-aftertranslatestarts-with, ends-with, containsstring-lengthconcatnormalize-space, normalize-unicode
Regular expressionsmatches, replace, tokenize
Arithmeticcountsum, avg, min, max, roundfloorceiling, abs
Dates and timesadjust-dateTime-to-timezone, current-dateTime, day-from-dateTime, month-from-dateTime, days-from-duration, months-from-duration, etc.
Properties of nodesname, node-name, local-namenamespace-uri, base-uri, nilled
Document handlingdoc, doc-available, document-uri, collection, id, idref
URIsencode-for-uri, escape-html-uri, iri-to-uri, resolve-uri
QNamesQName, namespace-uri-from-QName, prefix-from-QName, resolve-QName
Sequencesinsert-before, remove, subsequence, index-of, distinct-values, reverse, unordered, empty, exists
Type checkingone-or-more, exactly-one, zero-or-one
table from  wiki

This link gives SOME info of the useful XPath expressions 

http://saxon.sourceforge.net/saxon7.0/expressions.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值