Home » XML » XML XQuery : Istilah XQuery – Code dan Contohnya

XML XQuery : Istilah XQuery – Code dan Contohnya

by Hanifah Nurbaeti
by Hanifah Nurbaeti

XQuery Terminology

Node

Di XQuery, ada tujuh jenis node: node elemen, atribut, teks, namespace, instruksi-pemrosesan, komentar, dan dokumen (root).

Dokumen XML diperlakukan sebagai pohon node. Akar pohon disebut node dokumen (atau root node).

Lihat dokumen XML berikut ini:

<?xml version="1.0" encoding="UTF-8"?>

<bookstore>

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

</bookstore>

Contoh node dalam dokumen XML di atas:

<bookstore> (root node)

<author>J K. Rowling</author> (element node)

lang="en" (attribute node)

Nilai atom

Nilai atom adalah node tanpa anak atau induk.

Contoh nilai atom:

J K. Rowling

"en"

Item

Item adalah nilai atau node atom.

Hubungan Node

Induk(Parent)

Setiap elemen dan atribut memiliki satu induk.

Pada contoh berikut; unsur book adalah parents dari title, author, year, dan price:

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

Anak(Children)

Node elemen mungkin memiliki nol, satu atau lebih turunan.

Pada contoh berikut; elemen title, author, year, dan price semuanya merupakan child dari elemen book:

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

Saudara kandung(Siblings)

Node yang memiliki induk(parent) yang sama.

Pada contoh berikut; elemen title, author, year, dan price semuanya bersaudara(siblings):

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

Leluhur(Ancestor)

A node’s parent, parent’s parent, dll.

Pada contoh berikut; leluhur(ancestor) dari elemen title adalah elemen book dan elemen bookstore:

<bookstore>

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

</bookstore>

Keturunan(Descendats)

A node’s children, children’s children, dll.

Pada contoh berikut; Keturunan(descendats) elemen bookstore adalah elemen book, title, author, year, dan price :

<bookstore>

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

</bookstore>

You may also like