XQuery 術語
XQuery 術語表
節點
在 XQuery 中,有七種節點:元素、屬性、文字、名稱空間、處理指令、註釋和文件(根)節點。
XML 文件被視為節點樹。樹的根稱為文件節點(或根節點)。
檢視以下 XML 文件
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">哈利波特</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
以上 XML 文件中節點的示例
<bookstore> (根節點)
<author>J K. Rowling</author> (元素節點)
lang="en" (屬性節點)
原子值
原子值是沒有子節點或父節點的節點。
原子值示例
J K. Rowling
"en"
項
項是原子值或節點。
節點關係
父節點
每個元素和屬性都有一個父節點。
在以下示例中; book 元素是 title、author、year 和 price 的父節點
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
子節點
元素節點可以有零個、一個或多個子節點。
在以下示例中; title、author、year 和 price 元素都是 book 元素的子節點
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
同級節點
擁有相同父節點的節點。
在以下示例中; title、author、year 和 price 元素都是同級節點
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
祖先節點
一個節點的父節點、父節點的父節點等。
在以下示例中; title 元素的祖先是 book 元素和 bookstore 元素
<bookstore>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
後代節點
一個節點的子節點、子節點的子節點等。
在以下示例中; 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>