Terminologi XQuery

Dalam XQuery, terdapat tujuh jenis node: elemen, atribut, teks, ruang nama, perintah pengolahan, komen serta node dokumen (atau disebut root node).

Terminologi XQuery

Node

Dalam XQuery, terdapat tujuh jenis node: elemen, atribut, teks, ruang nama, perintah pengolahan, komen serta node dokumen (atau disebut root node). Dokumen XML dianggap sebagai pohon node. Akar pohon disebut node dokumen atau root node.

Lihat dokumen XML di bawah ini:

<?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>

Contoh node di dalam dokumen XML di atas:

<bookstore>  (node dokumen)
<author>J K. Rowling</author>  (node elemen)
lang="en"  (node atribut)

Nilai asas (atau disebut nilai atom, Atomic value)

Nilai asas adalah node tanpa bapak atau anak.

Contoh nilai asas:

J K. Rowling
"en"

Proyek

Proyek adalah nilai asas atau node.

Hubungan node

Bapak (Parent)

Setiap elemen serta atribut mempunyai bapak.

Di contoh yang berikut, elemen book adalah bapak bagi elemen title, author, year serta price:

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

Anak (Children)

Element node boleh mempunyai nol, satu atau lebih anak.

Di contoh yang berikut, elemen title, author, year serta price adalah anak bagi elemen book:

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

Saudara (Sibling)

Node yang memiliki ayah yang sama.

Di contoh yang berikut, elemen title, author, year serta price adalah saudara:

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

Bapak (Ancestor)

Ayahnya, ayah ayahnya, dan seterusnya.

Di contoh yang berikut, bapaknya bagi elemen title adalah elemen book dan bookstore:

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

Turunannya (Descendant)

Anak dari suatu node, anak-anak anak, dan seterusnya.

Di contoh yang berikut, turunannya daripada bookstore adalah elemen-elemen book, title, author, year serta price:

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