XPath(2) nodes, atomic value and sequence

In xPath1.0, evaluation of expression will return one of the four basic results, one is node-set the others are atomic types

boolean, number,string

In xPath2.0, every value is a sequence. the value of every expression is a sequence of zero or more items. 

Atomic value is just a special case of a sequence: it is a sequence of length one.


Nodes

7 types of nodes:
  • The document node (one per document)  - /
  • Element nodes
  • Attribute nodes
  • Text nodes
  • Comment nodes
  • Processing instruction nodes
  • Namespace nodes

Element node

The String value of an element node can be return by the <xsl:value-of select="nodeName"> eleent tage in XSLT.
The name of an element node can be returned by xPath function name().
The children of an element are the text, element, comment, and processing instruction nodes contained in the original element.

Attribute node

Although an element node is the parent of its attribute nodes, those attribute nodes are not children of their parent.


Node Test

From xPath 1.0:
node() - match all nodes
text() - text node only
comment() - nodes and axis
processing-instruction()
*
NCName:* - all nodes in a particular namespace

From xPath 2.0:
element() - checks element with an optional data type match.
schema-element
attribute() - match element with an optional data type match.
*:NCName - match regardless of namespace

Atomic values

xPath2.0 support all the basic datatypes in xml schema

xs:string - you can convert anything to a string by using string() function.

xs:boolean - you can use true() and false() function to evaluate the value

xs:decimal

xs:float and xs:double

xs:integer

xs:duration


xs:date - YYYY-MM-DD

xs:time- hh:mm:ss.sss

xs:dateTime

you can have a +|- sign to indicate time difference from UTC, like -05:00 after date or time

dateTime is the combination of xs:date and xs:time, separated by a single character T 1995-04-21T17:38:22.183-05:00


XML Schema defines the datatypes xs:gYearMonth, xs:gYear, xs:gMonthDay, gDay, and gMonth. 

Examples of these values, in order, are 1995-04 for April, 1995; 1995 for the year 1995; --04-21 for the 21st day of April; ---21 for the 21st day of a month; and --04 for April.


more datatypes:

xs:hexBinary and xs:base64Binary

xs:anyURI

xs:QName

xs:anyType and xs:anySimpleType 

xs:yearMonthDuration and xs:dayTimeDuration

xs:untyped and xs:untypedAtomic

xs:anyAtomicType


What is sequence?

Using nodes and atomic values we can derive the definition of sequence
Sequence is items.Sequences have no properties other than the items they contain.
Items are index from 1, the length can be obtained by count() function.
The items in a sequence are either  atomic values, or  node-set
An item is itself a sequence

types can have occurrence indicators + * ?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值