XQuery Functions

The same functions library is shared by XQuery 1.0, XPath 2.0, and XSLT 2.0. Built on XPath expressions, XQuery 1.0 and XPath 2.0 share the same data model. They also support the same functions and operators. It also facilitates us to define our own functions in XQuery. XQuery Data Types: The same data types as … Read more

XQuery Selecting and Filtering

Books.xml: ABC Author Name 2020 100.00 XQuery Book Author 1 Author 2 2005 300.00 Ecosystem Author Name 2010 250.00 Current Affairs Author Name 2004 500.00 Science Book Author 1 Author 2 Author 3 2011 150.00 Selecting and Filtering Elements: Using either a Path expression or with a FLWOR expression, we can select and filter the … Read more

XQuery Adding Elements and Attributes

Books.xml: ABC Author Name 2020 100.00 XQuery Book Author 1 Author 2 2005 300.00 Sociology 1 Author Name 2010 250.00 Current Affairs Author Name 2004 500.00 Science Book Author 1 Author 2 Author 3 2011 150.00 Adding Elements and Attributes to the Result: The elements and attributes can be added in the result from the … Read more

XQuery Syntax

There are some syntax rules defined for XQuery, such as, it is case-sensitive and that the elements, attributes, and variables in XQuery must be valid XML names. XQuery Basic Syntax Rules: Case-sensitive. Elements, attributes, and variables must be valid XML names. The string value can be in single or double-quotes. Variable is defined with a … Read more

XQuery Terms

Nodes: The element, attribute, text, namespace, processing-instruction, comment, and document nodes are the seven kinds of nodes in XQuery. The trees of nodes are the XML documents, and the root element is the topmost element of the tree. The document node is the root of the tree, also called the root node. Example: ABC Author … Read more

XQuery HTML

Books.xml: ABC Author Name 2020 100.00 XQuery Book Author 1 Author 2 2005 300.00 Sociology 1 Author Name 2010 250.00 Current Affairs Author Name 2004 500.00 Science Book Author 1 Author 2 Author 3 2011 150.00 Present the Result In an HTML List: Example 1: for $x in doc(“books.xml”)/bookstore/book/title order by $x return $x Explanation: … Read more

XQuery FLWOR Expressions

What is FLWOR? “For, Let, Where, Order by, Return” together makes the acronym FLWOR (pronounced as “flower”). For: To select a sequence of nodes. Let: To bind a sequence to a variable. Where: To filter the nodes. Order by: To sort the nodes. Return: To evaluate what to return, once for every node. Books.xml: ABC … Read more

XQuery Example

Books.xml: ABC Author Name 2020 100.00 XQuery Book Author 1 Author 2 2005 300.00 Sociology 1 Author Name 2010 250.00 Current Affairs Author Name 2004 500.00 Science Book Author 1 Author 2 Author 3 2011 150.00 To Select Nodes From “books.xml”: Functions: To extract data from XML documents, the functions in XQuery are used. Example: … Read more