Purpose | The <xselect> statement is used to perform a relational data query against a set of XML documents. | |||||||||||||||
Format |
<xselect resultNode="{result doc name}"> <nodes> <node alias="{node alias}" includepath="{path bool}">{node path}</node> </nodes> <from> <doc alias="{doc alias}">{doc file or XML}</doc> </from> <where> {where clause} </where> </xselect> {result doc name} |
the name of the resulting XML document node/element |
{node alias} |
the alias to be used as the name for the selected nodes whose name fits the {node path} |
{includepath} |
true means include the path of the selected node when constructing the result; false means omit the path and just include the last node itself without its ancestors |
{node path} |
the tree path (i.e. the fully qualified name) of the node to be selected in the joined set of XML documents-- the join functions similarly to a SQL SELECT statement's join |
{doc alias} |
the alias to be used as the name for the XML document in the {where clause} |
{doc file or XML} |
the path or URL to the XML document or the actual XML itself |
{where clause} |
the where clause performs the joins between the XML documents and also performs the inclusion check to consider which nodes in the XML documents to include in the resultset. The where clause includes <where> clauses and also <or> clauses which are of the following formats: |
<where datatype="{where datatype}" from="{from node}" op="{rel op}" to="{to node}" />
<where datatype="{where datatype}" op="{rel op}"> <or />
{where datatype} is the datatype to be used in performing the comparison between nodes
Please note also that in lieu of parentheses in a SQL SELECT statement, the <xselect> statement uses nested <where> clauses. The inner <where> clauses are processed before the outer ones. |
|
Example #1 |
Consider for this example that the file C:\\MyDir\\MyDoc.xml contains the following: <Emps company="TechInc"> <Emp status="aleph"> <Name f="Johnnie B" l="Goode">Bgoode</Name> <ID>123</ID> <Num>25</Num> </Emp> <Subsidiary> <ID>9000</ID> <Name>Toyz Co</Name> <Address> <Street>50 Some Street</Street> <City>Anytown</City> <nodes> <node>12345</node> <node>09876</node> </nodes> </Address> <free>Jack</free> </Subsidiary> <Emp status="beth"> <Name pseudo="no" nickname="yes">Sue</Name> <ID>245</ID> <Num>25</Num> </Emp> </Emps> Now consider the following code snippet:
The result is the following set of nodes. If the <xselect> statement were placed within an <xout> statement, for example, they would be sent to the output stream: |