Terminologi XQuery

Dalam XQuery, ada tujuh jenis node: elemen, atribut, teks, namespace, direktif pemrosesan, komentar, serta node dokumen (atau disebut root node).

Terminologi XQuery

Node

Dalam XQuery, ada tujuh jenis node: elemen, atribut, teks, namespace, direktif pemrosesan, komentar, 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 dasar (atau disebut nilai atom, Atomic value)

Nilai dasar adalah node tanpa orang tua atau tanpa anak.

Contoh nilai dasar:

J K. Rowling
"en"

Proyek

Proyek adalah nilai dasar atau node.

Hubungan Node

Orangtua (Parent)

Setiap elemen dan atribut memiliki satu orangtua.

Dalam contoh di bawah ini, elemen book adalah orangtua elemen-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)

Elemen node dapat memiliki nol, satu, atau banyak anak.

Dalam contoh di bawah ini, elemen-elemen title, author, year serta price adalah anak dari 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 orangtua yang sama.

Dalam contoh di bawah ini, elemen-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>

Orangtua (Ancestor)

Orangtua suatu node, orangtua orangtua, dan seterusnya.

Dalam contoh di bawah ini, penunjuk 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>

Anak (Descendant)

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

Dalam contoh di bawah ini, anak dari 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>