<xselect>

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}">
   <from>
      <parm type="{parm type}" name="{parm name}">
         {parm value}
      </parm>
      <expr>
         {expression}
      </expr>
   </from>
   <to>
      <parm type="{parm type}" name="{parm name}">
         {parm value}
      </parm>
      <expr>
         {expression}
      </expr>
   </to>
</where>

<or />

{where datatype} is the datatype to be used in performing the comparison between nodes
{from node} is the {doc alias} followed by a colon and then the name of the node on the left hand of the comparison
{rel op} is the relational operator to be used in the comparison
{to node} is the {doc alias} followed by a colon and then the name of the node on the right hand of the comparison
{parm type} is the datatype of the parameter to be substituted into {expression}
{parm name} is the name of the parameter to be substituted into {expression}
{parm value} is the value of the parameter to be substituted into {expression}
{expression} is the expression that specifies the node to be used in the comparison as the from or to node

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.
Adjacent <where> clauses are ANDed together implicitly. If there is an <or> clause between them then they are ORed together.

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:
<xselect resultNode="MyResults">
   <nodes>
      <node alias="MyName" includepath="true">Emps/Emp/Name</node>
      <node alias="The_ID" includepath="true">B:EmpID</node>
   </nodes>
   <from>
      <doc alias="A">C:\\MyDir\\MyDoc.xml</doc>
      <doc alias="B">
         <EmpAges>
            <EmpAge>
               <EmpID>123</EmpID>
               <Age>23</Age>
            </EmpAge>
            <EmpAge>
               <EmpID>9000</EmpID>
               <Age>25</Age>
            </EmpAge>
         </EmpAges>
      </doc>
   </from>
   <where>
      <where>
         <where datatype="int" from="1 * A:ID + 5" op="=" to="1 * B:EmpID + 5" join="inner" />
         <where datatype="int" from="A:Num" op="=" to="B:Age" join="inner" />
      </where>
      <or />

      <where datatype="int" from="A:Num" op="&gt;" to="23 + 1" />
      <where datatype="string" from="A:Name" op="!=" to="Sue" />
   </where>
</xselect>

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:
<MyResults>
   <MyName company="TechInc">
      <Emp status="aleph">
         <Name f="Johnnie B" l="Goode">Bgoode</Name>
      </Emp>
   </MyName>
   <The_ID>123</The_ID>
</MyResults>