![]() collect the child nodes that are elements.Īgain the double slash means select all the elements in the document.for each descendant node that is a element.for each node in the initial focus (the document node).We can paraphrase what the query engine does at each step: The first step creates the initial focus by calling the doc() function. This XQuery is a single path expression composed of three steps. The document node will have one child node, and that child node will represent the document element. The doc() function returns the document node, which becomes the singleton node in the initial focus set. The document element is the single, top-level XML element in the file. It represents the entire XML document, not the document element. The document node is a node constructed in memory, when the document is loaded. Note that the document node is not the same as the document element. The doc() function loads an XML document and returns the document node. Another common way is to let the XQuery itself create the initial focus by using the first step of the path expression to call the XQuery doc() function. With Qt XML Patterns, a standard way to present the initial focus to a query is to call QXmlQuery::setFocus(). The items in the result set are presented in document order and without duplicates. Evaluation of the final step produces the final result, which is the result of the XQuery. These evaluations produce a new set of items, called the result, which then becomes the focus that is passed to the next step. The step is evaluated for each item in the focus. A step is evaluated with a set of input items (nodes and atomic values), sometimes called the focus. This algorithm is evaluated by evaluating each step moving from left to right through the sequence. Think of a path expression as an algorithm for traversing an XML tree to find and collect items of interest. Although path expressions are used for traversing XML trees, not file systems, in Qt XML Patterns we can model a file system to look like an XML tree, so in Qt XML Patterns we can use XQuery to traverse a file system. It is a sequence of one or more steps separated by slash '/' or double slash '//'. In XQuery, we write these iterative and recursive algorithms with path expressions.Ī path expression looks somewhat like a typical file pathname for locating a file in a hierarchical file system. In C++ and Java, we write nested for loops and recursive functions to traverse XML trees in search of elements of interest. Using Path Expressions To Match And Select Items It creates a new element in the output and sets its id attribute to be the id attribute from an element in the other.html file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |