As we compare our times with saxon, attached are saxon's query execution
plans for our benchmark queries. The plans look very similar to the query
in structure. In our plans we have a rule that inlines assignments and thus
duplicates some let clauses when they are used multiple places. Saxon is
not doing that restructuring.

Just like our plans they have the initial paths steps close together. The
plans also have similar depth related to the number of expression in the
query. Saxon does have a optimization for the "some" clause which is not in
VXQuery. Not sure if that is something we can implement.
(: XQuery Filter Query :)
(: See historical data for Riverside, CA (ASN00008113) station by selecting   :)
(: the weather readings for December 25 over the last 10 years.               :)
let $collection := "/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
for $r in collection($collection)/dataCollection/data
let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
where $r/station eq "GHCND:ASN00008113" 
    and fn:year-from-date($date) ge 2003
    and fn:month-from-date($date) eq 12 
    and fn:day-from-date($date) eq 25
return $r


<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <FLWOR>
         <for var="r" slot="0">
            <filterExpression>
               <slash>
                  <sortAndDeduplicate intraDocument="false">
                     <slash>
                        <functionCall name="collection">
                           <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                    type="xs:string"/>
                        </functionCall>
                        <axis name="child" 
nodeTest="element(Q{}dataCollection)"/>
                     </slash>
                  </sortAndDeduplicate>
                  <axis name="child" nodeTest="element(Q{}data)"/>
               </slash>
               <operator op="eq">
                  <atomizeSingleton>
                     <axis name="child" nodeTest="element(Q{}station)"/>
                  </atomizeSingleton>
                  <literal value="GHCND:ASN00008113" type="xs:string"/>
               </operator>
            </filterExpression>
         </for>
         <let var="date" slot="1">
            <cast as="Q{http://www.w3.org/2001/XMLSchema}date";>
               <functionCall name="fn:substring">
                  <cast as="Q{http://www.w3.org/2001/XMLSchema}string";>
                     <atomizeSingleton>
                        <slash simple-step="true">
                           <variableReference name="r" slot="0"/>
                           <axis name="child" nodeTest="element(Q{}date)"/>
                        </slash>
                     </atomizeSingleton>
                  </cast>
                  <literal value="0" type="xs:integer"/>
                  <literal value="11" type="xs:integer"/>
               </functionCall>
            </cast>
         </let>
         <where>
            <operator op="ge">
               <functionCall name="fn:year-from-date">
                  <variableReference name="date" slot="1"/>
               </functionCall>
               <literal value="2003" type="xs:integer"/>
            </operator>
         </where>
         <where>
            <operator op="eq">
               <functionCall name="fn:month-from-date">
                  <variableReference name="date" slot="1"/>
               </functionCall>
               <literal value="12" type="xs:integer"/>
            </operator>
         </where>
         <where>
            <operator op="eq">
               <functionCall name="fn:day-from-date">
                  <variableReference name="date" slot="1"/>
               </functionCall>
               <literal value="25" type="xs:integer"/>
            </operator>
         </where>
         <return>
            <variableReference name="r" slot="0"/>
         </return>
      </FLWOR>
   </body>
</query>
(: XQuery Filter Query :)
(: Find all reading for hurricane force wind warning or extreme wind warning. :)
(: The warnings occur when the wind speed (AWND) exceeds 110 mph (49.1744     :)
(: meters per second). (Wind value is in tenth of a meter per second)         :)
let $collection := "/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
for $r in collection($collection)/dataCollection/data
where $r/dataType eq "AWND" and xs:decimal(fn:data($r/value)) gt 491.744
return $r


OPT ======================================
OPT : At line 6 of 
file:/Users/prestoncarman/Documents/smartsvn/vxquery_git_master/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/benchmarks/saxon/queries/q01.xq
OPT : Collapsed redundant for expression $r
OPT ====== Expression after rewrite ======
<filterExpression>
   <filterExpression>
      <slash>
         <sortAndDeduplicate intraDocument="false">
            <slash>
               <functionCall name="fn:collection">
                  <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                           type="xs:string"/>
               </functionCall>
               <axis name="child" nodeTest="element(Q{}dataCollection)"/>
            </slash>
         </sortAndDeduplicate>
         <axis name="child" nodeTest="element(Q{}data)"/>
      </slash>
      <operator op="gt">
         <cast as="Q{http://www.w3.org/2001/XMLSchema}decimal";>
            <atomizeSingleton>
               <axis name="child" nodeTest="element(Q{}value)"/>
            </atomizeSingleton>
         </cast>
         <literal value="49.1744" type="xs:decimal"/>
      </operator>
   </filterExpression>
   <operator op="eq">
      <atomizeSingleton>
         <axis name="child" nodeTest="element(Q{}dataType)"/>
      </atomizeSingleton>
      <literal value="AWND" type="xs:string"/>
   </operator>
</filterExpression>

OPT ======================================
<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <filterExpression>
         <filterExpression>
            <slash>
               <sortAndDeduplicate intraDocument="false">
                  <slash>
                     <functionCall name="fn:collection">
                        <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                 type="xs:string"/>
                     </functionCall>
                     <axis name="child" nodeTest="element(Q{}dataCollection)"/>
                  </slash>
               </sortAndDeduplicate>
               <axis name="child" nodeTest="element(Q{}data)"/>
            </slash>
            <operator op="gt">
               <cast as="Q{http://www.w3.org/2001/XMLSchema}decimal";>
                  <atomizeSingleton>
                     <axis name="child" nodeTest="element(Q{}value)"/>
                  </atomizeSingleton>
               </cast>
               <literal value="49.1744" type="xs:decimal"/>
            </operator>
         </filterExpression>
         <operator op="eq">
            <atomizeSingleton>
               <axis name="child" nodeTest="element(Q{}dataType)"/>
            </atomizeSingleton>
            <literal value="AWND" type="xs:string"/>
         </operator>
      </filterExpression>
   </body>
</query>
(: XQuery Aggregate Query :)
(: Find the annual precipitation (PRCP) for a Seattle using the airport       :)
(: station (USW00024233) for 1999.                                            :)
fn:sum(
    let $collection := "/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
    for $r in collection($collection)/dataCollection/data
    let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
    where $r/station eq "GHCND:USW00024233" 
        and $r/dataType eq "PRCP" 
        and fn:year-from-date($date) eq 1999
    return $r/value
) div 10



<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <operator op="div">
         <functionCall name="fn:sum">
            <for variable="r" as="element(Q{}data)">
               <in>
                  <filterExpression>
                     <filterExpression>
                        <filterExpression>
                           <slash>
                              <sortAndDeduplicate intraDocument="false">
                                 <slash>
                                    <functionCall name="collection">
                                       <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                                type="xs:string"/>
                                    </functionCall>
                                    <axis name="child" 
nodeTest="element(Q{}dataCollection)"/>
                                 </slash>
                              </sortAndDeduplicate>
                              <axis name="child" nodeTest="element(Q{}data)"/>
                           </slash>
                           <operator op="eq">
                              <functionCall name="fn:year-from-date">
                                 <cast 
as="Q{http://www.w3.org/2001/XMLSchema}date";>
                                    <functionCall name="substring">
                                       <cast 
as="Q{http://www.w3.org/2001/XMLSchema}string";>
                                          <atomizeSingleton>
                                             <axis name="child" 
nodeTest="element(Q{}date)"/>
                                          </atomizeSingleton>
                                       </cast>
                                       <literal value="0" type="xs:integer"/>
                                       <literal value="11" type="xs:integer"/>
                                    </functionCall>
                                 </cast>
                              </functionCall>
                              <literal value="1999" type="xs:integer"/>
                           </operator>
                        </filterExpression>
                        <operator op="eq">
                           <atomizeSingleton>
                              <axis name="child" 
nodeTest="element(Q{}dataType)"/>
                           </atomizeSingleton>
                           <literal value="PRCP" type="xs:string"/>
                        </operator>
                     </filterExpression>
                     <operator op="eq">
                        <atomizeSingleton>
                           <axis name="child" nodeTest="element(Q{}station)"/>
                        </atomizeSingleton>
                        <literal value="GHCND:USW00024233" type="xs:string"/>
                     </operator>
                  </filterExpression>
               </in>
               <return>
                  <data>
                     <slash simple-step="true">
                        <variableReference name="r" slot="0"/>
                        <axis name="child" nodeTest="element(Q{}value)"/>
                     </slash>
                  </data>
               </return>
            </for>
         </functionCall>
         <literal value="10" type="xs:integer"/>
      </operator>
   </body>
</query>
(: XQuery Aggregate Query :)
(: Find the highest recorded temperature (TMAX) in Celsius.                   :)
fn:max(
    let $collection := "/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
    for $r in collection($collection)/dataCollection/data
    where $r/dataType eq "TMAX"
    return $r/value
) div 10


<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <operator op="div">
         <functionCall name="fn:max">
            <for variable="r" as="element(Q{}data)">
               <in>
                  <filterExpression>
                     <slash>
                        <slash>
                           <functionCall name="collection">
                              <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                       type="xs:string"/>
                           </functionCall>
                           <axis name="child" 
nodeTest="element(Q{}dataCollection)"/>
                        </slash>
                        <axis name="child" nodeTest="element(Q{}data)"/>
                     </slash>
                     <operator op="eq">
                        <atomizeSingleton>
                           <axis name="child" nodeTest="element(Q{}dataType)"/>
                        </atomizeSingleton>
                        <literal value="TMAX" type="xs:string"/>
                     </operator>
                  </filterExpression>
               </in>
               <return>
                  <data>
                     <slash simple-step="true">
                        <variableReference name="r" slot="0"/>
                        <axis name="child" nodeTest="element(Q{}value)"/>
                     </slash>
                  </data>
               </return>
            </for>
         </functionCall>
         <literal value="10" type="xs:integer"/>
      </operator>
   </body>
</query>
(: XQuery Join Query :)
(: Find all the weather readings for Los Angeles county for a specific day    :)
(: 1976/7/4.                                                                  :)
let $collection1 := "/tmp/1.0_partition_ghcnd_all_xml/stations/collection.xml"
for $s in collection($collection1)/stationCollection/station

let $collection2 := "/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
for $r in collection($collection2)/dataCollection/data
    
let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
where $s/id eq $r/station 
    and (some $x in $s/locationLabels satisfies ($x/type eq "CNTY" and 
$x/displayName eq "Los Angeles County, CA"))
    and $date eq xs:date("1976-07-04")
return $r



OPT ======================================
OPT : At line 8 of 
file:/Users/prestoncarman/Documents/smartsvn/vxquery_git_master/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/benchmarks/saxon/queries/q04.xq
OPT : Subexpression extracted from filter because independent of context
OPT ====== Expression after rewrite ======
<let variable="Q{http://saxon.sf.net/}zz911091865";
     as="xs:untypedAtomic?"
     slot="-999">
   <be>
      <atomizeSingleton>
         <slash simple-step="true">
            <variableReference name="s" slot="-999"/>
            <axis name="child" nodeTest="element(Q{}id)"/>
         </slash>
      </atomizeSingleton>
   </be>
   <return>
      <filterExpression>
         <filterExpression>
            <slash>
               <sortAndDeduplicate intraDocument="false">
                  <slash>
                     <functionCall name="collection">
                        <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                 type="xs:string"/>
                     </functionCall>
                     <axis name="child" nodeTest="element(Q{}dataCollection)"/>
                  </slash>
               </sortAndDeduplicate>
               <axis name="child" nodeTest="element(Q{}data)"/>
            </slash>
            <operator op="eq">
               <cast as="Q{http://www.w3.org/2001/XMLSchema}date";>
                  <functionCall name="substring">
                     <cast as="Q{http://www.w3.org/2001/XMLSchema}string";>
                        <atomizeSingleton>
                           <axis name="child" nodeTest="element(Q{}date)"/>
                        </atomizeSingleton>
                     </cast>
                     <literal value="0" type="xs:integer"/>
                     <literal value="11" type="xs:integer"/>
                  </functionCall>
               </cast>
               <literal value="1976-07-04" type="xs:date"/>
            </operator>
         </filterExpression>
         <operator op="eq">
            <variableReference name="Q{http://saxon.sf.net/}zz911091865"; 
slot="-999"/>
            <atomizeSingleton>
               <axis name="child" nodeTest="element(Q{}station)"/>
            </atomizeSingleton>
         </operator>
      </filterExpression>
   </return>
</let>

OPT ======================================
OPT ======================================
OPT : At line 8 of 
file:/Users/prestoncarman/Documents/smartsvn/vxquery_git_master/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/benchmarks/saxon/queries/q04.xq
OPT : Collapsed redundant for expression $r
OPT ====== Expression after rewrite ======
<let variable="Q{http://saxon.sf.net/}zz911091865";
     as="xs:untypedAtomic?"
     slot="-999">
   <be>
      <atomizeSingleton>
         <slash simple-step="true">
            <variableReference name="s" slot="-999"/>
            <axis name="child" nodeTest="element(Q{}id)"/>
         </slash>
      </atomizeSingleton>
   </be>
   <return>
      <filterExpression>
         <filterExpression>
            <slash>
               <sortAndDeduplicate intraDocument="false">
                  <slash>
                     <functionCall name="collection">
                        <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                 type="xs:string"/>
                     </functionCall>
                     <axis name="child" nodeTest="element(Q{}dataCollection)"/>
                  </slash>
               </sortAndDeduplicate>
               <axis name="child" nodeTest="element(Q{}data)"/>
            </slash>
            <operator op="eq">
               <cast as="Q{http://www.w3.org/2001/XMLSchema}date";>
                  <functionCall name="substring">
                     <cast as="Q{http://www.w3.org/2001/XMLSchema}string";>
                        <atomizeSingleton>
                           <axis name="child" nodeTest="element(Q{}date)"/>
                        </atomizeSingleton>
                     </cast>
                     <literal value="0" type="xs:integer"/>
                     <literal value="11" type="xs:integer"/>
                  </functionCall>
               </cast>
               <literal value="1976-07-04" type="xs:date"/>
            </operator>
         </filterExpression>
         <operator op="eq">
            <variableReference name="Q{http://saxon.sf.net/}zz911091865"; 
slot="-999"/>
            <atomizeSingleton>
               <axis name="child" nodeTest="element(Q{}station)"/>
            </atomizeSingleton>
         </operator>
      </filterExpression>
   </return>
</let>

OPT ======================================
<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <for variable="s" as="element(Q{}station)">
         <in>
            <filterExpression>
               <slash>
                  <sortAndDeduplicate intraDocument="false">
                     <slash>
                        <functionCall name="collection">
                           <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/stations/collection.xml"
                                    type="xs:string"/>
                        </functionCall>
                        <axis name="child" 
nodeTest="element(Q{}stationCollection)"/>
                     </slash>
                  </sortAndDeduplicate>
                  <axis name="child" nodeTest="element(Q{}station)"/>
               </slash>
               <some variable="x">
                  <in>
                     <axis name="child" nodeTest="element(Q{}locationLabels)"/>
                  </in>
                  <satisfies>
                     <operator op="and">
                        <operator op="eq">
                           <atomizeSingleton>
                              <slash simple-step="true">
                                 <variableReference name="x" slot="1"/>
                                 <axis name="child" 
nodeTest="element(Q{}type)"/>
                              </slash>
                           </atomizeSingleton>
                           <literal value="CNTY" type="xs:string"/>
                        </operator>
                        <operator op="eq">
                           <atomizeSingleton>
                              <slash simple-step="true">
                                 <variableReference name="x" slot="1"/>
                                 <axis name="child" 
nodeTest="element(Q{}displayName)"/>
                              </slash>
                           </atomizeSingleton>
                           <literal value="Los Angeles County, CA" 
type="xs:string"/>
                        </operator>
                     </operator>
                  </satisfies>
               </some>
            </filterExpression>
         </in>
         <return>
            <let variable="Q{http://saxon.sf.net/}zz911091865";
                 as="xs:untypedAtomic?"
                 slot="2">
               <be>
                  <atomizeSingleton>
                     <slash simple-step="true">
                        <variableReference name="s" slot="0"/>
                        <axis name="child" nodeTest="element(Q{}id)"/>
                     </slash>
                  </atomizeSingleton>
               </be>
               <return>
                  <filterExpression>
                     <filterExpression>
                        <slash>
                           <sortAndDeduplicate intraDocument="false">
                              <slash>
                                 <functionCall name="collection">
                                    <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                             type="xs:string"/>
                                 </functionCall>
                                 <axis name="child" 
nodeTest="element(Q{}dataCollection)"/>
                              </slash>
                           </sortAndDeduplicate>
                           <axis name="child" nodeTest="element(Q{}data)"/>
                        </slash>
                        <operator op="eq">
                           <cast as="Q{http://www.w3.org/2001/XMLSchema}date";>
                              <functionCall name="substring">
                                 <cast 
as="Q{http://www.w3.org/2001/XMLSchema}string";>
                                    <atomizeSingleton>
                                       <axis name="child" 
nodeTest="element(Q{}date)"/>
                                    </atomizeSingleton>
                                 </cast>
                                 <literal value="0" type="xs:integer"/>
                                 <literal value="11" type="xs:integer"/>
                              </functionCall>
                           </cast>
                           <literal value="1976-07-04" type="xs:date"/>
                        </operator>
                     </filterExpression>
                     <operator op="eq">
                        <variableReference 
name="Q{http://saxon.sf.net/}zz911091865"; slot="2"/>
                        <atomizeSingleton>
                           <axis name="child" nodeTest="element(Q{}station)"/>
                        </atomizeSingleton>
                     </operator>
                  </filterExpression>
               </return>
            </let>
         </return>
      </for>
   </body>
</query>
(: XQuery Join Aggregate Query :)
(: Find the lowest recorded temperature (TMIN) in the state of Oregon for     :)
(: 2001.                                                                      :)
fn:min(
    let $collection1 := 
"/tmp/1.0_partition_ghcnd_all_xml/stations/collection.xml"
    for $s in collection($collection1)/stationCollection/station
    
    let $collection2 := 
"/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
    for $r in collection($collection2)/dataCollection/data
    
    let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
    where $s/id eq $r/station
        and (some $x in $s/locationLabels satisfies ($x/type eq "ST" and 
$x/displayName eq "Oregon”))
        and $r/dataType eq "TMIN" 
        and fn:year-from-date($date) eq 2001
    return $r/value
) div 10


OPT ======================================
OPT : At line 9 of 
file:/Users/prestoncarman/Documents/smartsvn/vxquery_git_master/vxquery-benchmark/src/main/resources/noaa-ghcn-daily/benchmarks/saxon/queries/q05.xq
OPT : Subexpression extracted from filter because independent of context
OPT ====== Expression after rewrite ======
<let variable="Q{http://saxon.sf.net/}zz968209473";
     as="xs:untypedAtomic?"
     slot="-999">
   <be>
      <atomizeSingleton>
         <slash simple-step="true">
            <variableReference name="s" slot="-999"/>
            <axis name="child" nodeTest="element(Q{}id)"/>
         </slash>
      </atomizeSingleton>
   </be>
   <return>
      <filterExpression>
         <filterExpression>
            <filterExpression>
               <slash>
                  <slash>
                     <functionCall name="collection">
                        <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                 type="xs:string"/>
                     </functionCall>
                     <axis name="child" nodeTest="element(Q{}dataCollection)"/>
                  </slash>
                  <axis name="child" nodeTest="element(Q{}data)"/>
               </slash>
               <operator op="eq">
                  <functionCall name="fn:year-from-date">
                     <cast as="Q{http://www.w3.org/2001/XMLSchema}date";>
                        <functionCall name="substring">
                           <cast as="Q{http://www.w3.org/2001/XMLSchema}string";>
                              <atomizeSingleton>
                                 <axis name="child" 
nodeTest="element(Q{}date)"/>
                              </atomizeSingleton>
                           </cast>
                           <literal value="0" type="xs:integer"/>
                           <literal value="11" type="xs:integer"/>
                        </functionCall>
                     </cast>
                  </functionCall>
                  <literal value="2001" type="xs:integer"/>
               </operator>
            </filterExpression>
            <operator op="eq">
               <atomizeSingleton>
                  <axis name="child" nodeTest="element(Q{}dataType)"/>
               </atomizeSingleton>
               <literal value="TMIN" type="xs:string"/>
            </operator>
         </filterExpression>
         <operator op="eq">
            <variableReference name="Q{http://saxon.sf.net/}zz968209473"; 
slot="-999"/>
            <atomizeSingleton>
               <axis name="child" nodeTest="element(Q{}station)"/>
            </atomizeSingleton>
         </operator>
      </filterExpression>
   </return>
</let>

OPT ======================================
<query>
   <globalVariables>
      <declareVariable name="saxon:context-item">
         <error message="Context item is absent"/>
      </declareVariable>
   </globalVariables>
   <body>
      <operator op="div">
         <functionCall name="fn:min">
            <for variable="s" as="element(Q{}station)">
               <in>
                  <filterExpression>
                     <slash>
                        <slash>
                           <functionCall name="collection">
                              <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/stations/collection.xml"
                                       type="xs:string"/>
                           </functionCall>
                           <axis name="child" 
nodeTest="element(Q{}stationCollection)"/>
                        </slash>
                        <axis name="child" nodeTest="element(Q{}station)"/>
                     </slash>
                     <some variable="x">
                        <in>
                           <axis name="child" 
nodeTest="element(Q{}locationLabels)"/>
                        </in>
                        <satisfies>
                           <operator op="and">
                              <operator op="eq">
                                 <atomizeSingleton>
                                    <slash simple-step="true">
                                       <variableReference name="x" slot="1"/>
                                       <axis name="child" 
nodeTest="element(Q{}type)"/>
                                    </slash>
                                 </atomizeSingleton>
                                 <literal value="ST" type="xs:string"/>
                              </operator>
                              <operator op="eq">
                                 <atomizeSingleton>
                                    <slash simple-step="true">
                                       <variableReference name="x" slot="1"/>
                                       <axis name="child" 
nodeTest="element(Q{}displayName)"/>
                                    </slash>
                                 </atomizeSingleton>
                                 <literal value="Oregon" type="xs:string"/>
                              </operator>
                           </operator>
                        </satisfies>
                     </some>
                  </filterExpression>
               </in>
               <return>
                  <for variable="r" as="element(Q{}data)">
                     <in>
                        <let variable="Q{http://saxon.sf.net/}zz968209473";
                             as="xs:untypedAtomic?"
                             slot="3">
                           <be>
                              <atomizeSingleton>
                                 <slash simple-step="true">
                                    <variableReference name="s" slot="0"/>
                                    <axis name="child" 
nodeTest="element(Q{}id)"/>
                                 </slash>
                              </atomizeSingleton>
                           </be>
                           <return>
                              <filterExpression>
                                 <filterExpression>
                                    <filterExpression>
                                       <slash>
                                          <slash>
                                             <functionCall name="collection">
                                                <literal 
value="/tmp/1.0_partition_ghcnd_all_xml/sensors/collection.xml"
                                                         type="xs:string"/>
                                             </functionCall>
                                             <axis name="child" 
nodeTest="element(Q{}dataCollection)"/>
                                          </slash>
                                          <axis name="child" 
nodeTest="element(Q{}data)"/>
                                       </slash>
                                       <operator op="eq">
                                          <functionCall 
name="fn:year-from-date">
                                             <cast 
as="Q{http://www.w3.org/2001/XMLSchema}date";>
                                                <functionCall name="substring">
                                                   <cast 
as="Q{http://www.w3.org/2001/XMLSchema}string";>
                                                      <atomizeSingleton>
                                                         <axis name="child" 
nodeTest="element(Q{}date)"/>
                                                      </atomizeSingleton>
                                                   </cast>
                                                   <literal value="0" 
type="xs:integer"/>
                                                   <literal value="11" 
type="xs:integer"/>
                                                </functionCall>
                                             </cast>
                                          </functionCall>
                                          <literal value="2001" 
type="xs:integer"/>
                                       </operator>
                                    </filterExpression>
                                    <operator op="eq">
                                       <atomizeSingleton>
                                          <axis name="child" 
nodeTest="element(Q{}dataType)"/>
                                       </atomizeSingleton>
                                       <literal value="TMIN" type="xs:string"/>
                                    </operator>
                                 </filterExpression>
                                 <operator op="eq">
                                    <variableReference 
name="Q{http://saxon.sf.net/}zz968209473"; slot="3"/>
                                    <atomizeSingleton>
                                       <axis name="child" 
nodeTest="element(Q{}station)"/>
                                    </atomizeSingleton>
                                 </operator>
                              </filterExpression>
                           </return>
                        </let>
                     </in>
                     <return>
                        <data>
                           <slash simple-step="true">
                              <variableReference name="r" slot="2"/>
                              <axis name="child" nodeTest="element(Q{}value)"/>
                           </slash>
                        </data>
                     </return>
                  </for>
               </return>
            </for>
         </functionCall>
         <literal value="10" type="xs:integer"/>
      </operator>
   </body>
</query>

Reply via email to