XQuery is a language for querying the contents of XML documents represented as values in the XQuery data model. In HiRDB, the contents of XML documents are stored in XML type values, and XQuery expressions are specified in the XMLQUERY function and the XMLEXISTS predicate in order to extract specific substructures from the XML document.
The XQuery data model represents XML document information as a tree structure. The XQuery data model consists of six kinds of nodes. These nodes hold information such as the names used to identify XML elements and attributes (qualified names), and the atomic values whose types are XQuery data types. XQuery is used to execute queries on values in the XQuery data model that are represented in the nodes and atomic values that hold such information.
The figure below shows a conceptual diagram of a query in XQuery. An XML document ((a) in the figure) is represented as a tree ((b) in the figure) in the XQuery data model. For the XQuery data model tree, the XQuery query that was entered ((c) in the figure) is evaluated, and a specified substructure ((d) in the figure) is extracted from the tree. The substructure extracted by the XQuery query also becomes a value represented in the model. The extracted substructure can be represented as a character string in the XML document format ((e) in the figure).
Figure 1-11 Conceptual diagram of a query in XQuery