Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XQuery Terminology

XQuery Terminology


In XQuery, there are seven kinds of nodes: elements, attributes, text, namespaces, processing instructions, comments, and document nodes (also called root nodes).


XQuery Terminology

Node

In XQuery, there are seven kinds of nodes: elements, attributes, text, namespaces, processing instructions, comments, and document (root) nodes. An XML document is treated as a tree of nodes. The root of the tree is called the document node or root node.

See the XML document below:

  Harry Potter

  J K. Rowling

  2005

  29.99

Examples of nodes in the XML document above:

(document node)

J K. Rowling (element node)

lang="en" (attribute node)

An atomic value is a node with no parent and no children.

Examples of atomic values:

J K. Rowling

"en"

Projects

An item is an atomic value or a node.


Node relationships

Parent

Every element and attribute has a parent.

In the example below, the book element is the parent of the title, author, year and price elements:


  Harry Potter
  J K. Rowling
  2005
  29.99

Children

A node element may have zero, one, or more children.

In the example below, the title, author, year and price elements are all children of the book element:


  Harry Potter
  J K. Rowling
  2005
  29.99

Siblings

Nodes that share the same parent.

In the example below, the title, author, year and price elements are all siblings:


  Harry Potter
  J K. Rowling
  2005
  29.99

Ancestors

A node's parent, its parent's parent, and so on.

In the example below, the ancestors of the title element are the book element and the bookstore element:




  Harry Potter
  J K. Rowling
  2005
  29.99


Descendants

A node's children, its children's children, and so on.

In the example below, the descendants of bookstore are book, title, author, year, and price elements:




  Harry Potter
  J K. Rowling
  2005
  29.99