XQuery 用語

在 XQuery 中,有七种节点:元素、属性、文本、命名空间、处理指令、注释、以及文档节点(或称为根节点)。

XQuery 用語

节点

在 XQuery 中,有七种节点:元素、属性、文本、命名空间、处理指令、注释、以及文档(根)节点。XML 文档是被作为节点树来对待的。树的根被称为文档节点或者根节点。

请看下面的 XML 文档:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author> 
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>

上面的 XML 文档中的节点例子:

<bookstore>  (文档节点)
<author>J K. Rowling</author>  (元素节点)
lang="en"  (属性节点)

基本值(或称原子值,Atomic value)

基本值是无父或无子的节点。

基本值的例子:

J K. Rowling
"en"

プロジェクト

プロジェクトは基本値またはノードです。

ノード関係

親(Parent)

各要素と属性には親があります。

以下の例では、book 要素は title、author、year そして price 要素の親です:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

子(Children)

ノード要素は子を持つことができますが、持たないこともあります。

以下の例では、title、author、year そして price 要素は book 要素の子です:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

兄弟(Sibling)

同じ親を持つノード。

以下の例では、title、author、year そして price 要素は兄弟です:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

祖先(Ancestor)

あるノードの親、親の親、など。

以下の例では、title 要素の祖先は book 要素と bookstore 要素です:

<bookstore>
<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>

子孫(Descendant)

あるノードの子孫、孫、など。

以下の例では、bookstore の子孫は book、title、author、year そして price 要素です:

<bookstore>
<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>