Added mail address

Added mail address

svn path=/trunk/eXist-1.0/; revision=4211

declare option exist:serialize "method=xml indent=yes";
declare option exist:output-size-limit "-1";
declare namespace response="http://exist-db.org/xquery/response";

let $product-version := util:system-property("product-version")
let $product-build := util:system-property("product-build")
let $test-suite := doc('/db/XQTS/XQTSCatalog.xml')/*:test-suite/@version
let $dummy := response:set-header("Content-Disposition", concat(
	"attachment; filename="results_XQTS-" , $test-suite , "_eXist-" ,
	$product-version , '_' , $product-build , ".xml"" ) )

return
<test-suite-result xmlns="http://www.w3.org/2005/02/query-test-XQTSResult"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <implementation name="eXist-{$product-version}" version="{$product-build}" anonymous-result-column="false">

                <organization name="eXist Open Source native XML database"  website="http://www.exist-db.org" anonymous="false"/>

                <submittor name="eXist XQTS testsuite runner" email="xqts@exist-db.org"/>

                <description>

eXist is an Open Source native XML database featuring efficient,
                        index-based XQuery processing, automatic indexing, extensions for full-text
                        search,  XUpdate  support and tight integration with existing XML development tools.

                </description>

                <implementation-defined-items>

                </implementation-defined-items>

                <features>
{ for $feature in doc('/db/XQTS/XQTSCatalog.xml')/*:test-suite/*:features/*:feature
							return
							<feature name="{$feature/@name}" supported="true"/>
						}</features>

                <context-properties>

                </context-properties>

        </implementation>

        <syntax>XQuery</syntax>

        <test-run dateRun="{fn:current-dateTime()}">
                <test-suite version="{$test-suite}"/>
                <transformation>

No unusual transformations.

                </transformation>
                <comparison>

No unusual comparisons

                </comparison>
                <otherComments>

The test run took n seconds.

                </otherComments>
        </test-run>

{
		(: for $case in fn:collection(  '/db/XQTS' )//*:test-case :)
    for $case in fn:collection(  '/db/XQTS' )//test-case
    return <test-case name="{$case/@name}" result="{$case/@result}" />
}
</test-suite-result>

declare option exist:serialize "method=xml indent=yes";
declare option exist:output-size-limit "-1";
declare namespace response="http://exist-db.org/xquery/response";

let $product-version := util:system-property("product-version")
let $product-build := util:system-property("product-build")
let $test-suite := doc('/db/XQTS/XQTSCatalog.xml')/*:test-suite/@version
let $dummy := response:set-header("Content-Disposition", concat(
	"attachment; filename="results_XQTS-" , $test-suite , "_eXist-" ,
	$product-version , '_' , $product-build , ".xml"" ) )

return
<test-suite-result xmlns="http://www.w3.org/2005/02/query-test-XQTSResult"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

        <implementation name="eXist-{$product-version}" version="{$product-build}" anonymous-result-column="false">

                <organization name="eXist Open Source native XML database"  website="http://www.exist-db.org" anonymous="false"/>

                <submittor name="eXist XQTS testsuite runner" email="me@not.com"/>

                <description>

eXist is an Open Source native XML database featuring efficient,
                        index-based XQuery processing, automatic indexing, extensions for full-text
                        search,  XUpdate  support and tight integration with existing XML development tools.

                </description>

                <implementation-defined-items>

                </implementation-defined-items>

                <features>
{ for $feature in doc('/db/XQTS/XQTSCatalog.xml')/*:test-suite/*:features/*:feature
							return
							<feature name="{$feature/@name}" supported="true"/>
						}</features>

                <context-properties>

                </context-properties>

        </implementation>

        <syntax>XQuery</syntax>

        <test-run dateRun="{fn:current-dateTime()}">
                <test-suite version="{$test-suite}"/>
                <transformation>

No unusual transformations.

                </transformation>
                <comparison>

No unusual comparisons

                </comparison>
                <otherComments>

The test run took n seconds.

                </otherComments>
        </test-run>

{
		(: for $case in fn:collection(  '/db/XQTS' )//*:test-case :)
    for $case in fn:collection(  '/db/XQTS' )//test-case
    return <test-case name="{$case/@name}" result="{$case/@result}" />
}
</test-suite-result>


slide xquery

slide xquery

declare namespace ism = "urn:us:gov:ic:ism";
let $sample := fn:doc("/sample.xml")
let $classification := $sample/*:contract/*:name/@*:classification
let $slide:=
  <p:sld xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
    <p:cSld>
      <p:spTree>
        <p:nvGrpSpPr>
          <p:cNvPr id="1" name="" />
          <p:cNvGrpSpPr />
          <p:nvPr />
        </p:nvGrpSpPr>
        <p:grpSpPr>
          <a:xfrm>
            <a:off x="0" y="0" />
            <a:ext cx="0" cy="0" />
            <a:chOff x="0" y="0" />
            <a:chExt cx="0" cy="0" />
          </a:xfrm>
        </p:grpSpPr>
        <p:sp>
          <p:nvSpPr>
            <p:cNvPr id="2" name="Title 1"/>
            <p:cNvSpPr>
              <a:spLocks noGrp="1"/>
            </p:cNvSpPr>
            <p:nvPr>
              <p:ph type="ctrTitle"/>
            </p:nvPr>
          </p:nvSpPr>
          <p:spPr>
            <a:xfrm>
              <a:off x="1020002" y="586887"/>
              <a:ext cx="7772400" cy="614728"/>
            </a:xfrm>
            <a:noFill/>
          </p:spPr>
          <p:txBody>
            <a:bodyPr>
              <a:normAutofit fontScale="90000"/>
            </a:bodyPr>
            <a:lstStyle/>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0"/>
                <a:t>{fn:concat(fn:concat("(",$classification),") ")} {$sample/*:contract/*:name/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US"/>
            </a:p>
          </p:txBody>
        </p:sp>
        <p:sp>
          <p:nvSpPr>
            <p:cNvPr id="4" name="TextBox 3" />
            <p:cNvSpPr txBox="1" />
            <p:nvPr />
          </p:nvSpPr>
          <p:spPr>
            <a:xfrm>
              <a:off x="1241321" y="1381240" />
              <a:ext cx="7428829" cy="369332" />
            </a:xfrm>
            <a:prstGeom prst="rect">
              <a:avLst />
            </a:prstGeom>
            <a:noFill />
          </p:spPr>
        </p:sp>
        <p:sp>
          <p:nvSpPr>
            <p:cNvPr id="3" name="Subtitle 3"/>
            <p:cNvSpPr>
              <a:spLocks noGrp="1"/>
            </p:cNvSpPr>
            <p:nvPr>
              <p:ph idx="1"/>
            </p:nvPr>
          </p:nvSpPr>
          <p:spPr>
            <a:xfrm>
              <a:off x="762000" y="1447800"/>
              <a:ext cx="8229600" cy="1905000"/>
            </a:xfrm>
          </p:spPr>
          <p:txBody>
            <a:bodyPr/>
            <a:lstStyle/>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>NUMBER : {$sample/*:contract/*:number/text()}</a:t>
              </a:r>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>PURPOSE : {fn:concat(fn:concat("(",$classification),") ")} {$sample/*:contract/*:purpose/text()}</a:t>
              </a:r>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>TYPE : {$sample/*:contract/*:type/text()}</a:t>
              </a:r>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>CEILING : {$sample/*:contract/*:ceiling/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US" sz="1400"/>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>FUNDING STATUS : {$sample/*:contract/*:funding-status/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US" sz="1400"/>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>PERIOD OF PERFORMANCE : {$sample/*:contract/*:period-of-performance-start/text()} - {$sample/*:contract/*:period-of-performance-end/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US" sz="1400"/>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>PRIME CONTRACTOR : {$sample/*:contract/*:prime-contractor/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US" sz="1400"/>
            </a:p>
            <a:p>
              <a:r>
                <a:rPr dirty="0" lang="en-US" smtClean="0" sz="1400"/>
                <a:t>FOLLOW ON: {$sample/*:contract/*:follow-on/text()}</a:t>
              </a:r>
              <a:endParaRPr dirty="0" lang="en-US" sz="1400"/>
            </a:p>
          </p:txBody>
        </p:sp>
        <p:graphicFrame>
          <p:nvGraphicFramePr>
            <p:cNvPr id="11" name="Table 10" />
            <p:cNvGraphicFramePr>
              <a:graphicFrameLocks noGrp="1" />
            </p:cNvGraphicFramePr>
            <p:nvPr>
              <p:extLst>
                <p:ext uri="{{D42A27DB-BD31-4B8C-83A1-F6EECF244321}}">
                  <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="2099691409" />
                </p:ext>
              </p:extLst>
            </p:nvPr>
          </p:nvGraphicFramePr>
          <p:xfrm>
            <a:off x="1881075" y="3975016" />
            <a:ext cx="6349840" cy="1483360" />
          </p:xfrm>
          <a:graphic>
            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">
              <a:tbl>
                <a:tblPr firstRow="1" bandRow="1">
                  <a:tableStyleId>{{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}}</a:tableStyleId>
                </a:tblPr>
                <a:tblGrid>
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                </a:tblGrid>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Task Name</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Start Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>End Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Duration</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Status</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                </a:tr>{
                for $t in $sample/*:contract/*:schedule/*:task
                return
                  <a:tr h="370840">
                    <a:tc>
                      <a:txBody>
                        <a:bodyPr />
                        <a:lstStyle />
                        <a:p>
                          <a:r>
                            <a:rPr lang="en-US" dirty="0" smtClean="0" />
                            <a:t>{$t/*:name/text()}</a:t>
                          </a:r>
                          <a:endParaRPr lang="en-US" dirty="0" />
                        </a:p>
                      </a:txBody>
                      <a:tcPr />
                    </a:tc>
                    <a:tc>
                      <a:txBody>
                        <a:bodyPr />
                        <a:lstStyle />
                        <a:p>
                          <a:r>
                            <a:rPr lang="is-IS" dirty="0" smtClean="0" />
                            <a:t>{$t/*:start-date/text()}</a:t>
                          </a:r>
                          <a:endParaRPr lang="en-US" dirty="0" />
                        </a:p>
                      </a:txBody>
                      <a:tcPr />
                    </a:tc>
                    <a:tc>
                      <a:txBody>
                        <a:bodyPr />
                        <a:lstStyle />
                        <a:p>
                          <a:r>
                            <a:rPr lang="is-IS" dirty="0" smtClean="0" />
                            <a:t>{$t/*:end-date/text()}</a:t>
                          </a:r>
                          <a:endParaRPr lang="en-US" dirty="0" />
                        </a:p>
                      </a:txBody>
                      <a:tcPr />
                    </a:tc>
                    <a:tc>
                      <a:txBody>
                        <a:bodyPr />
                        <a:lstStyle />
                        <a:p>
                          <a:r>
                            <a:rPr lang="en-US" dirty="0" smtClean="0" />
                            <a:t>{$t/*:duration-days/text()}</a:t>
                          </a:r>
                          <a:endParaRPr lang="en-US" dirty="0" />
                        </a:p>
                      </a:txBody>
                      <a:tcPr />
                    </a:tc>
                    <a:tc>
                      <a:txBody>
                        <a:bodyPr />
                        <a:lstStyle />
                        <a:p>
                          <a:r>
                            <a:rPr lang="en-US" dirty="0" smtClean="0" />
                            <a:t>{$t/*:status/text()}</a:t>
                          </a:r>
                          <a:endParaRPr lang="en-US" dirty="0" />
                        </a:p>
                      </a:txBody>
                      <a:tcPr />
                    </a:tc>
                  </a:tr>
              }
              </a:tbl>
            </a:graphicData>
          </a:graphic>
        </p:graphicFrame>
      </p:spTree>
      <p:extLst>
        <p:ext uri="{{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}}">
          <p14:creationId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="2670298589" />
        </p:ext>
      </p:extLst>
    </p:cSld>
    <p:clrMapOvr>
      <a:masterClrMapping />
    </p:clrMapOvr>
  </p:sld>
return
(:xdmp:document-insert("/content/Users/adhavle/Demos/Q4-2015/marklogic-powerpoint-master/src/main/resources/powerpoint/ppt/slides/slide1.xml", $ppt-template-simple):)
  xdmp:save("/Users/adhavle/Demos/Q4-2015/powerpoint/marklogic-powerpoint/src/main/resources/powerpoint/ppt/slides/slide1.xml" , $slide)

xquery version "1.0-ml";

let $sample := fn:doc("/sample.xml")
let $slide:=
  <p:sld xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
    <p:cSld>
      <p:spTree>
        <p:nvGrpSpPr>
          <p:cNvPr id="1" name="" />
          <p:cNvGrpSpPr />
          <p:nvPr />
        </p:nvGrpSpPr>
        <p:grpSpPr>
          <a:xfrm>
            <a:off x="0" y="0" />
            <a:ext cx="0" cy="0" />
            <a:chOff x="0" y="0" />
            <a:chExt cx="0" cy="0" />
          </a:xfrm>
        </p:grpSpPr>
        <p:sp>
          <p:nvSpPr>
            <p:cNvPr id="2" name="Title 1" />
            <p:cNvSpPr>
              <a:spLocks noGrp="1" />
            </p:cNvSpPr>
            <p:nvPr>
              <p:ph type="ctrTitle" />
            </p:nvPr>
          </p:nvSpPr>
          <p:spPr>
            <a:xfrm>
              <a:off x="1020002" y="586887" />
              <a:ext cx="7772400" cy="614728" />
            </a:xfrm>
            <a:solidFill>
              <a:srgbClr val="DCE6F2" />
            </a:solidFill>
          </p:spPr>
          <p:txBody>
            <a:bodyPr>
              <a:normAutofit fontScale="90000" />
            </a:bodyPr>
            <a:lstStyle />
            <a:p>
              <a:r>
                <a:rPr lang="en-US" dirty="0" smtClean="0" />
                <a:t>{$sample/contract/name/text()}</a:t>
              </a:r>
              <a:endParaRPr lang="en-US" dirty="0" />
            </a:p>
          </p:txBody>
        </p:sp>
        <p:sp>
          <p:nvSpPr>
            <p:cNvPr id="4" name="TextBox 3" />
            <p:cNvSpPr txBox="1" />
            <p:nvPr />
          </p:nvSpPr>
          <p:spPr>
            <a:xfrm>
              <a:off x="1241321" y="1381240" />
              <a:ext cx="7428829" cy="369332" />
            </a:xfrm>
            <a:prstGeom prst="rect">
              <a:avLst />
            </a:prstGeom>
            <a:noFill />
          </p:spPr>
          <p:txBody>
            <a:bodyPr wrap="square" rtlCol="0">
              <a:spAutoFit />
            </a:bodyPr>
            <a:lstStyle />
            <a:p>
              <a:pPr algn="ctr" />

              <a:r>
                <a:rPr lang="en-US" dirty="0" smtClean="0" />
                <a:t>{$sample/contract/purpose/text()}</a:t>
              </a:r>
              <a:endParaRPr lang="en-US" dirty="0" />
            </a:p>
          </p:txBody>
        </p:sp>
        <p:graphicFrame>
          <p:nvGraphicFramePr>
            <p:cNvPr id="7" name="Table 6" />
            <p:cNvGraphicFramePr>
              <a:graphicFrameLocks noGrp="1" />
            </p:cNvGraphicFramePr>
            <p:nvPr>
              <p:extLst>
                <p:ext uri="{{D42A27DB-BD31-4B8C-83A1-F6EECF244321}}">
                  <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="278749714" />
                </p:ext>
              </p:extLst>
            </p:nvPr>
          </p:nvGraphicFramePr>
          <p:xfrm>
            <a:off x="1881075" y="1858445" />
            <a:ext cx="6349840" cy="741680" />
          </p:xfrm>
          <a:graphic>
            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">
              <a:tbl>
                <a:tblPr firstRow="1" bandRow="1">
                  <a:tableStyleId>{{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}}</a:tableStyleId>
                </a:tblPr>
                <a:tblGrid>
                  <a:gridCol w="1277750" />
                  <a:gridCol w="1277750" />
                  <a:gridCol w="1277750" />
                  <a:gridCol w="1265718" />
                  <a:gridCol w="1250872" />
                </a:tblGrid>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Type</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Ceiling</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Funding</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Start Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>End Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                </a:tr>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>{$sample/contract/type/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>{$sample/contract/ceiling/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>{$sample/contract/funding-status/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>{$sample/contract/period-of-performance-start/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="fi-FI" dirty="0" smtClean="0" />
                          <a:t>{$sample/contract/period-of-performance-end/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                </a:tr>
              </a:tbl>
            </a:graphicData>
          </a:graphic>
        </p:graphicFrame>
        <p:graphicFrame>
          <p:nvGraphicFramePr>
            <p:cNvPr id="9" name="Table 8" />
            <p:cNvGraphicFramePr>
              <a:graphicFrameLocks noGrp="1" />
            </p:cNvGraphicFramePr>
            <p:nvPr>
              <p:extLst>
                <p:ext uri="{{D42A27DB-BD31-4B8C-83A1-F6EECF244321}}">
                  <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="1554662600" />
                </p:ext>
              </p:extLst>
            </p:nvPr>
          </p:nvGraphicFramePr>
          <p:xfrm>
            <a:off x="1881075" y="2743297" />
            <a:ext cx="6349840" cy="1010920" />
          </p:xfrm>
          <a:graphic>
            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">
              <a:tbl>
                <a:tblPr firstRow="1" bandRow="1">
                  <a:tableStyleId>{{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}}</a:tableStyleId>
                </a:tblPr>
                <a:tblGrid>
                  <a:gridCol w="2071017" />
                  <a:gridCol w="4278823" />
                </a:tblGrid>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Prime Contractor</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" sz="1800" kern="1200" dirty="0" smtClean="0">
                            <a:solidFill>
                              <a:schemeClr val="dk1" />
                            </a:solidFill>
                            <a:latin typeface="+mn-lt" />
                            <a:ea typeface="+mn-ea" />
                            <a:cs typeface="+mn-cs" />
                          </a:rPr>
                          <a:t>{$sample/contract/prime-contractor/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" sz="1800" kern="1200" dirty="0">
                          <a:solidFill>
                            <a:schemeClr val="dk1" />
                          </a:solidFill>
                          <a:latin typeface="+mn-lt" />
                          <a:ea typeface="+mn-ea" />
                          <a:cs typeface="+mn-cs" />
                        </a:endParaRPr>
                      </a:p>
                    </a:txBody>
                    <a:tcPr>
                      <a:solidFill>
                        <a:schemeClr val="accent1">
                          <a:lumMod val="20000" />
                          <a:lumOff val="80000" />
                        </a:schemeClr>
                      </a:solidFill>
                    </a:tcPr>
                  </a:tc>
                </a:tr>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" sz="1800" b="1" kern="1200" dirty="0" smtClean="0">
                            <a:solidFill>
                              <a:schemeClr val="lt1" />
                            </a:solidFill>
                            <a:latin typeface="+mn-lt" />
                            <a:ea typeface="+mn-ea" />
                            <a:cs typeface="+mn-cs" />
                          </a:rPr>
                          <a:t>Follow-on</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr>
                      <a:solidFill>
                        <a:schemeClr val="accent1" />
                      </a:solidFill>
                    </a:tcPr>
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" sz="1800" b="1" kern="1200" dirty="0" smtClean="0">
                            <a:solidFill>
                              <a:schemeClr val="dk1" />
                            </a:solidFill>
                            <a:latin typeface="+mn-lt" />
                            <a:ea typeface="+mn-ea" />
                            <a:cs typeface="+mn-cs" />
                          </a:rPr>
                          <a:t>{$sample/contract/follow-on/text()}</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" sz="1800" b="1" kern="1200" dirty="0">
                          <a:solidFill>
                            <a:schemeClr val="dk1" />
                          </a:solidFill>
                          <a:latin typeface="+mn-lt" />
                          <a:ea typeface="+mn-ea" />
                          <a:cs typeface="+mn-cs" />
                        </a:endParaRPr>
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                </a:tr>
              </a:tbl>
            </a:graphicData>
          </a:graphic>
        </p:graphicFrame>
        <p:graphicFrame>
          <p:nvGraphicFramePr>
            <p:cNvPr id="11" name="Table 10" />
            <p:cNvGraphicFramePr>
              <a:graphicFrameLocks noGrp="1" />
            </p:cNvGraphicFramePr>
            <p:nvPr>
              <p:extLst>
                <p:ext uri="{{D42A27DB-BD31-4B8C-83A1-F6EECF244321}}">
                  <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="2099691409" />
                </p:ext>
              </p:extLst>
            </p:nvPr>
          </p:nvGraphicFramePr>
          <p:xfrm>
            <a:off x="1881075" y="3975016" />
            <a:ext cx="6349840" cy="1483360" />
          </p:xfrm>
          <a:graphic>
            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">
              <a:tbl>
                <a:tblPr firstRow="1" bandRow="1">
                  <a:tableStyleId>{{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}}</a:tableStyleId>
                </a:tblPr>
                <a:tblGrid>
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                  <a:gridCol w="1269968" />
                </a:tblGrid>
                <a:tr h="370840">
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Task Name</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Start Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>End Date</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Duration</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                  <a:tc>
                    <a:txBody>
                      <a:bodyPr />
                      <a:lstStyle />
                      <a:p>
                        <a:r>
                          <a:rPr lang="en-US" dirty="0" smtClean="0" />
                          <a:t>Status</a:t>
                        </a:r>
                        <a:endParaRPr lang="en-US" dirty="0" />
                      </a:p>
                    </a:txBody>
                    <a:tcPr />
                  </a:tc>
                </a:tr>
                {
                  for $task in $sample/contract/*:schedule/*:task
                  return
                    <a:tr h="370840">
                      <a:tc>
                        <a:txBody>
                          <a:bodyPr />
                          <a:lstStyle />
                          <a:p>
                            <a:r>
                              <a:rPr lang="en-US" dirty="0" smtClean="0" />
                              <a:t>{$task/*:name/text()}</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US" dirty="0" />
                          </a:p>
                        </a:txBody>
                        <a:tcPr />
                      </a:tc>
                      <a:tc>
                        <a:txBody>
                          <a:bodyPr />
                          <a:lstStyle />
                          <a:p>
                            <a:r>
                              <a:rPr lang="is-IS" dirty="0" smtClean="0" />
                              <a:t>{$task/*:start-date/text()}</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US" dirty="0" />
                          </a:p>
                        </a:txBody>
                        <a:tcPr />
                      </a:tc>
                      <a:tc>
                        <a:txBody>
                          <a:bodyPr />
                          <a:lstStyle />
                          <a:p>
                            <a:r>
                              <a:rPr lang="is-IS" dirty="0" smtClean="0" />
                              <a:t>{$task/*:end-date/text()}</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US" dirty="0" />
                          </a:p>
                        </a:txBody>
                        <a:tcPr />
                      </a:tc>
                      <a:tc>
                        <a:txBody>
                          <a:bodyPr />
                          <a:lstStyle />
                          <a:p>
                            <a:r>
                              <a:rPr lang="en-US" dirty="0" smtClean="0" />
                              <a:t>{$task/*:duration-days/text()}</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US" dirty="0" />
                          </a:p>
                        </a:txBody>
                        <a:tcPr />
                      </a:tc>
                      <a:tc>
                        <a:txBody>
                          <a:bodyPr />
                          <a:lstStyle />
                          <a:p>
                            <a:r>
                              <a:rPr lang="en-US" dirty="0" smtClean="0" />
                              <a:t>{$task/*:status/text()}</a:t>
                            </a:r>
                            <a:endParaRPr lang="en-US" dirty="0" />
                          </a:p>
                        </a:txBody>
                        <a:tcPr />
                      </a:tc>
                    </a:tr>
                }
              </a:tbl>
            </a:graphicData>
          </a:graphic>
        </p:graphicFrame>
      </p:spTree>
      <p:extLst>
        <p:ext uri="{{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}}">
          <p14:creationId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="2670298589" />
        </p:ext>
      </p:extLst>
    </p:cSld>
    <p:clrMapOvr>
      <a:masterClrMapping />
    </p:clrMapOvr>
  </p:sld>
return
(:xdmp:document-insert("/content/Users/adhavle/Demos/Q4-2015/marklogic-powerpoint-master/src/main/resources/powerpoint/ppt/slides/slide1.xml", $ppt-template-simple):)
  (
    xdmp:log("now saving template"),
    xdmp:save("/Users/adhavle/Demos/Q4-2015/marklogic-powerpoint-master/src/main/resources/powerpoint/ppt/slides/slide1.xml" , $slide)
  )


MarkLogic: Create a local:eval-database helper function.


Corrected oxy web author environment variable name.


Refined offending tests : the definitive set

svn path=/trunk/eXist-1.0/; revision=3700

declare namespace xqts="http://exist-db.org/xquery/xqts";
declare namespace catalog="http://www.w3.org/2005/02/query-test-XQTSCatalog";

declare namespace props="java:java.io.File";

import module namespace util="http://exist-db.org/xquery/util";
import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace xdiff="http://exist-db.org/xquery/xmldiff"
at "java:org.exist.xquery.modules.xmldiff.XmlDiffModule";
import module namespace request="http://exist-db.org/xquery/request";

(:~ ----------------------------------------------------------------------------------------
     W3C XQuery Test Suite

     This is the main module for running the XQTS on eXist. You can either
     run the whole test suite, a specific test group or a single test case.

     Setup:

     * Make sure the XmlDiff module is registered in conf.xml

     * Edit config.xml and change basedir to point to the directory into
     which you unzipped the XQTS sources. Note: it needs to be an URI.

     * Create a collection /db/XQTS in the database.

     * From the XQTS directory, upload XQTSCatalog.xml into the created
     collection.

     * Upload the "TestSources" directory so the source docs can be found
     in /db/XQTS/TestSources.

     * Run this script with the client.
     ------------------------------------------------------------------------------------------- :)
declare variable $xqts:CONFIG { xqts:initialize() };
declare variable $xqts:XQTS_HOME { xqts:path-to-uri($xqts:CONFIG/basedir/text()) };

declare function xqts:initialize() as element() {
    let $home := util:system-property("exist.home")
    let $path := concat($home, "/webapp/xqts")
    let $collection := xdb:create-collection("/db", "XQTS")
    let $config0 := doc("/db/XQTS")/config
    let $config :=
        if ($config0) then
            $config0
        else
            let $stored := xdb:store-files-from-pattern("/db/XQTS", $path, "*.xml", "text/xml")
            return
                doc("/db/XQTS/config.xml")/config
    let $xqtsHome := $config/basedir/text()
    let $catalog0 := doc("/db/XQTS/XQTSCatalog.xml")
    let $catalog :=
        if ($catalog0) then $catalog0
        else
            xdb:store($collection, "XQTSCatalog.xml",
                xs:anyURI(xqts:path-to-uri(concat($xqtsHome, "XQTSCatalog.xml"))))
    let $sources0 := collection("/db/XQTS/TestSources")
    let $sources :=
        if ($sources0) then
            $sources0
        else
            let $sourceCol := xdb:create-collection("/db/XQTS", "TestSources")
            return
                xdb:store-files-from-pattern($sourceCol, concat($xqtsHome, "TestSources"), "*.xml", "text/xml")
    return
        $config
};

declare function xqts:path-to-uri($path as xs:string) as xs:string {
        if (starts-with($path, "/")) then
            concat("file://", $path)
        else
            concat("file:///", $path)
};

declare function xqts:create-progress-file($testCount as xs:int) as empty() {
    let $results := xdb:store("/db/XQTS", "progress.xml",
        <progress total="{$testCount}" done="0" failed="0" passed="0"/>)
    return ()
};

declare function xqts:report-progress($test-case as element()) as empty() {
    let $result := string($test-case/@result)
    let $progress := doc("/db/XQTS/progress.xml")/progress
    let $counter := $progress/@done
    return (
        update value $counter with xs:int($counter + 1),
        if ($result eq 'fail') then
            update value $progress/@failed with xs:int($progress/@failed + 1)
        else
            update value $progress/@passed with xs:int($progress/@passed + 1)
    )
};

declare function xqts:create-collections($group as element(catalog:test-group)) as node() {
    let $rootColl := xdb:create-collection("/db/XQTS", "test-results")
    let $ancestors := reverse(($group/ancestor::catalog:test-group, $group))
    let $collection := xqts:create-collections($rootColl, $ancestors, "/db/XQTS/test-results")
    let $results := xdb:store($collection, "results.xml", <test-result failed="0" passed="0"/>)
    return
        doc($results)
};

declare function xqts:create-collections($parent as object,
    $pathElements as element()+, $currentPath as xs:string)
as object {
    let $next := $pathElements[last()]
    let $remainder := subsequence($pathElements, 1, count($pathElements) - 1)
    let $newColl := xdb:create-collection($parent, $next/@name)
    return
        if ($remainder) then
            xqts:create-collections($newColl, $remainder, concat($currentPath, "/", $next/@name))
        else
            $newColl
};

declare function xqts:get-query($case as element(catalog:test-case)) {
   let $query-name := $case//catalog:query/@name
   let $path := concat( $xqts:XQTS_HOME, "Queries/XQuery/", $case/@FilePath, $query-name, ".xq" )
   let $xq-string := util:file-read($path)
   return $xq-string
};

declare function xqts:print-result($test-name as xs:string, $passed as xs:boolean, $query as xs:string,
    $result as item()*, $expected as item()*, $case as element(catalog:test-case)) as element() {
    <test-case name="{$test-name}" result="{if ($passed) then 'pass' else 'fail'}">
    {
        if (not($passed)) then (
            <result>{$result}</result>,
            if ($expected instance of element() and count($expected/*) > 10) then
            	<expected truncated="">{$expected/*[position() < 10]}</expected>
            else
                <expected>{$expected}</expected>,
            (: element {$case/catalog:input-file/@variable} { xqts:getInputValue($case) }, :)
            <query>{$query}</query>
        ) else ()
    }
    </test-case>
};

declare function xqts:normalize-text($result as item()*) as xs:string {
    let $str := string-join($result, " ")
    return
        (: Remove leading and trailing whitespace :)
        replace(replace($str, "^\s+", ""), "\s+$", "")
};

declare function xqts:check-output($query as xs:string, $result as item()*, $case as element(catalog:test-case)) {
    let $output := $case/catalog:output-file[last()]
    return
        (: Expected an error, but got a result :)
        if (exists($case/catalog:expected-error)) then
            <test-case name="{$case/@name}" result="fail">
                   <expected-error>{$case/catalog:expected-error/text()}</expected-error>
                   <query>{$query}</query>
            </test-case>
        (: Comparison method: "Text" :)
        else if ($output/@compare eq "Text") then
            let $text := util:file-read(concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                "/", $output/text()))
            let $test := xqts:normalize-text($text) eq xqts:normalize-text($result)
            return
                xqts:print-result($case/@name, $test, $query, $result, $text, $case)
        (: Comparison method: "XML" :)
        else if ($output/@compare eq "XML") then
            util:catch("java.lang.Exception",
                let $filePath := concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                    $output/text())
                let $expected := doc(xdb:store("/db", "temp.xml", xs:anyURI($filePath), "text/xml"))
                let $test := xdiff:compare($expected, $result)
                return
                    xqts:print-result($case/@name, $test, $query, $result, $expected, $case),
                (: Handle unexpected exceptions :)
                <test-case name="{$case/@name}" result="fail">
                   <exception>Exception while loading expected result: {$util:exception-message}</exception>
                   <query>{$query}</query>
                </test-case>
            )
        (: Comparison method: "Fragment" :)
        else if ($output/@compare eq "Fragment") then
            util:catch("java.lang.Exception",
                let $filePath := concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath, $output/text())
                let $expectedFrag := util:file-read($filePath)
                let $xmlFrag := concat("<f>", $expectedFrag, "</f>")
                let $log := util:log("DEBUG", ("Frag stored: ", $xmlFrag))
                let $expected := doc(xdb:store("/db", "temp.xml", $xmlFrag, "text/xml"))
                let $test := xdiff:compare($expected, <f>{$result}</f>)
                return
                    xqts:print-result($case/@name, $test, $query, $result, $expected, $case),
                (: Handle unexpected exceptions :)
                <test-case name="{$case/@name}" result="fail">
                   <exception>Exception while loading expected result fragment: {$util:exception-message}</exception>
                   <query>{$query}</query>
                </test-case>
            )
        (: Comparison method: "Inspect" :)
        (: A text compare is sufficient in many test cases :)
        else if ($output/@compare eq "Inspect") then
            let $text := util:file-read(concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                "/", $output/text()))
            let $test := xqts:normalize-text($text) eq xqts:normalize-text($result)
            return
                xqts:print-result($case/@name, $test, $query, $result, $text, $case)

        (: Don't know how to compare :)
        else
            <error test="{$case/@name}">Unknown comparison method: {$output/@compare}.</error>
};

declare function xqts:run-test-case( $case as element(catalog:test-case)) as item()* {
   let $query := xqts:get-query($case)
   let $context :=
       <static-context>
       {
           for $input in $case/catalog:input-file
           return
               <variable name="{$input/@variable}">{xqts:get-input-value($input)}</variable>
       }
       </static-context>
   let $result :=
       util:catch("java.lang.Exception",
           let $result :=
               util:eval-with-context($query, $context, false())
           return
               xqts:check-output($query, $result, $case),
           if ($case//catalog:expected-error) then
               <test-case name="{$case/@name}" result="pass">
                   <exception>{$util:exception-message}</exception>
                   <expected-error>{$case//catalog:expected-error/text()}</expected-error>
                   <query>{$query}</query>
               </test-case>
           else
               <test-case name="{$case/@name}" result="fail">
                   <exception>{$util:exception-message}</exception>
                   <query>{$query}</query>
               </test-case>
       )
   return $result
};

declare function xqts:finish($result as element()) as empty() {
    let $passed := count($result//test-case[@result = 'pass'])
    let $failed := count($result//test-case[@result = 'fail'])
    return (
        update value $result/@passed with xs:int($passed),
        update value $result/@failed with xs:int($failed)
    )
};

declare function xqts:run-single-test-case($case as element(catalog:test-case),
    $resultRoot as element()?) as empty() {
    let $result := xqts:run-test-case($case)
    return (
        update insert $result into $resultRoot,
        let $added := $resultRoot/test-case[@name = $case/@name]
        return
            if ($added) then xqts:report-progress($added)
            else ()
    )
};

declare function xqts:run-test-group($group as element(catalog:test-group)) as empty() {
    (: Create the collection hierarchy for this group and get the results.xml doc to
        append to. :)
    let $resultsDoc := xqts:create-collections($group)
    let $tests := $group/catalog:test-case[
    	not(starts-with(@name, 'Constr-inscope-10')) and
    	not(starts-with(@name, 'Constr-inscope-12')) and
    	not(starts-with(@name, 'Constr-namespace-22'))
    	]
    return (
        (: Execute the test cases :)
        for $test in $tests
        let $log := util:log("DEBUG", ("Running test case: ", string($test/@name)))
        return
            xqts:run-single-test-case($test, $resultsDoc/test-result),
        if ($tests) then
            xqts:finish($resultsDoc/test-result)
        else
            xdb:remove(util:collection-name($resultsDoc), util:document-name($resultsDoc)),
        (: Execute tests in child groups :)
        for $childGroup in $group/catalog:test-group
        let $log := util:log("DEBUG", ("Entering group: ", string($childGroup/@name)))
        return
            xqts:run-test-group($childGroup)
    )
};

declare function xqts:test-single($name as xs:string) as element() {
    let $test := //catalog:test-case[@name = $name]
    return
        if ($test) then
            let $resultsDoc := xqts:create-collections($test/parent::catalog:test-group)
            let $dummy := xqts:run-single-test-case($test, $resultsDoc/test-result)
            return
                $resultsDoc/test-result
        else
            <error>Test case not found: {$name}.</error>
};

declare function xqts:test-group($groupName as xs:string) as empty() {
    let $group := //catalog:test-group[@name = $groupName]
    return (
        xqts:create-progress-file(count($group//catalog:test-case)),
        xqts:run-test-group($group)
    )
};

declare function xqts:test-all() as empty() {
    for $test in /catalog:test-suite/catalog:test-group
    return
        xqts:test-group($test/@name)
};

declare function xqts:get-input-value($input as element(catalog:input-file)) as item()* {
   if ($input eq "emptydoc") then
       ()
   else (
       let $source := root($input)//catalog:source[@ID = $input/text()]
       return
           if (empty($source)) then
               concat("no input found: ", $input/text())
           else
               doc(concat("/db/XQTS/", $source/@FileName))
   )
};

declare function xqts:overall-result() {
    let $passed := count(//test-case[@result = "pass"])
    let $failed := count(//test-case[@result = "fail"])
    return
        <test-result failed="{$failed}" passed="{$passed}"
            percentage="{$passed div ($passed + $failed)}"/>
};

let $group := request:get-parameter('group', ())
return
    if ($group) then
        xqts:test-group($group)
    else
        ()

declare namespace xqts="http://exist-db.org/xquery/xqts";
declare namespace catalog="http://www.w3.org/2005/02/query-test-XQTSCatalog";

declare namespace props="java:java.io.File";

import module namespace util="http://exist-db.org/xquery/util";
import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace xdiff="http://exist-db.org/xquery/xmldiff"
at "java:org.exist.xquery.modules.xmldiff.XmlDiffModule";
import module namespace request="http://exist-db.org/xquery/request";

(:~ ----------------------------------------------------------------------------------------
     W3C XQuery Test Suite

     This is the main module for running the XQTS on eXist. You can either
     run the whole test suite, a specific test group or a single test case.

     Setup:

     * Make sure the XmlDiff module is registered in conf.xml

     * Edit config.xml and change basedir to point to the directory into
     which you unzipped the XQTS sources. Note: it needs to be an URI.

     * Create a collection /db/XQTS in the database.

     * From the XQTS directory, upload XQTSCatalog.xml into the created
     collection.

     * Upload the "TestSources" directory so the source docs can be found
     in /db/XQTS/TestSources.

     * Run this script with the client.
     ------------------------------------------------------------------------------------------- :)
declare variable $xqts:CONFIG { xqts:initialize() };
declare variable $xqts:XQTS_HOME { xqts:path-to-uri($xqts:CONFIG/basedir/text()) };

declare function xqts:initialize() as element() {
    let $home := util:system-property("exist.home")
    let $path := concat($home, "/webapp/xqts")
    let $collection := xdb:create-collection("/db", "XQTS")
    let $config0 := doc("/db/XQTS")/config
    let $config :=
        if ($config0) then
            $config0
        else
            let $stored := xdb:store-files-from-pattern("/db/XQTS", $path, "*.xml", "text/xml")
            return
                doc("/db/XQTS/config.xml")/config
    let $xqtsHome := $config/basedir/text()
    let $catalog0 := doc("/db/XQTS/XQTSCatalog.xml")
    let $catalog :=
        if ($catalog0) then $catalog0
        else
            xdb:store($collection, "XQTSCatalog.xml",
                xs:anyURI(xqts:path-to-uri(concat($xqtsHome, "XQTSCatalog.xml"))))
    let $sources0 := collection("/db/XQTS/TestSources")
    let $sources :=
        if ($sources0) then
            $sources0
        else
            let $sourceCol := xdb:create-collection("/db/XQTS", "TestSources")
            return
                xdb:store-files-from-pattern($sourceCol, concat($xqtsHome, "TestSources"), "*.xml", "text/xml")
    return
        $config
};

declare function xqts:path-to-uri($path as xs:string) as xs:string {
        if (starts-with($path, "/")) then
            concat("file://", $path)
        else
            concat("file:///", $path)
};

declare function xqts:create-progress-file($testCount as xs:int) as empty() {
    let $results := xdb:store("/db/XQTS", "progress.xml",
        <progress total="{$testCount}" done="0" failed="0" passed="0"/>)
    return ()
};

declare function xqts:report-progress($test-case as element()) as empty() {
    let $result := string($test-case/@result)
    let $progress := doc("/db/XQTS/progress.xml")/progress
    let $counter := $progress/@done
    return (
        update value $counter with xs:int($counter + 1),
        if ($result eq 'fail') then
            update value $progress/@failed with xs:int($progress/@failed + 1)
        else
            update value $progress/@passed with xs:int($progress/@passed + 1)
    )
};

declare function xqts:create-collections($group as element(catalog:test-group)) as node() {
    let $rootColl := xdb:create-collection("/db/XQTS", "test-results")
    let $ancestors := reverse(($group/ancestor::catalog:test-group, $group))
    let $collection := xqts:create-collections($rootColl, $ancestors, "/db/XQTS/test-results")
    let $results := xdb:store($collection, "results.xml", <test-result failed="0" passed="0"/>)
    return
        doc($results)
};

declare function xqts:create-collections($parent as object,
    $pathElements as element()+, $currentPath as xs:string)
as object {
    let $next := $pathElements[last()]
    let $remainder := subsequence($pathElements, 1, count($pathElements) - 1)
    let $newColl := xdb:create-collection($parent, $next/@name)
    return
        if ($remainder) then
            xqts:create-collections($newColl, $remainder, concat($currentPath, "/", $next/@name))
        else
            $newColl
};

declare function xqts:get-query($case as element(catalog:test-case)) {
   let $query-name := $case//catalog:query/@name
   let $path := concat( $xqts:XQTS_HOME, "Queries/XQuery/", $case/@FilePath, $query-name, ".xq" )
   let $xq-string := util:file-read($path)
   return $xq-string
};

declare function xqts:print-result($test-name as xs:string, $passed as xs:boolean, $query as xs:string,
    $result as item()*, $expected as item()*, $case as element(catalog:test-case)) as element() {
    <test-case name="{$test-name}" result="{if ($passed) then 'pass' else 'fail'}">
    {
        if (not($passed)) then (
            <result>{$result}</result>,
            if ($expected instance of element() and count($expected/*) > 10) then
            	<expected truncated="">{$expected/*[position() < 10]}</expected>
            else
                <expected>{$expected}</expected>,
            (: element {$case/catalog:input-file/@variable} { xqts:getInputValue($case) }, :)
            <query>{$query}</query>
        ) else ()
    }
    </test-case>
};

declare function xqts:normalize-text($result as item()*) as xs:string {
    let $str := string-join($result, " ")
    return
        (: Remove leading and trailing whitespace :)
        replace(replace($str, "^\s+", ""), "\s+$", "")
};

declare function xqts:check-output($query as xs:string, $result as item()*, $case as element(catalog:test-case)) {
    let $output := $case/catalog:output-file[last()]
    return
        (: Expected an error, but got a result :)
        if (exists($case/catalog:expected-error)) then
            <test-case name="{$case/@name}" result="fail">
                   <expected-error>{$case/catalog:expected-error/text()}</expected-error>
                   <query>{$query}</query>
            </test-case>
        (: Comparison method: "Text" :)
        else if ($output/@compare eq "Text") then
            let $text := util:file-read(concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                "/", $output/text()))
            let $test := xqts:normalize-text($text) eq xqts:normalize-text($result)
            return
                xqts:print-result($case/@name, $test, $query, $result, $text, $case)
        (: Comparison method: "XML" :)
        else if ($output/@compare eq "XML") then
            util:catch("java.lang.Exception",
                let $filePath := concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                    $output/text())
                let $expected := doc(xdb:store("/db", "temp.xml", xs:anyURI($filePath), "text/xml"))
                let $test := xdiff:compare($expected, $result)
                return
                    xqts:print-result($case/@name, $test, $query, $result, $expected, $case),
                (: Handle unexpected exceptions :)
                <test-case name="{$case/@name}" result="fail">
                   <exception>Exception while loading expected result: {$util:exception-message}</exception>
                   <query>{$query}</query>
                </test-case>
            )
        (: Comparison method: "Fragment" :)
        else if ($output/@compare eq "Fragment") then
            util:catch("java.lang.Exception",
                let $filePath := concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath, $output/text())
                let $expectedFrag := util:file-read($filePath)
                let $xmlFrag := concat("<f>", $expectedFrag, "</f>")
                let $log := util:log("DEBUG", ("Frag stored: ", $xmlFrag))
                let $expected := doc(xdb:store("/db", "temp.xml", $xmlFrag, "text/xml"))
                let $test := xdiff:compare($expected, <f>{$result}</f>)
                return
                    xqts:print-result($case/@name, $test, $query, $result, $expected, $case),
                (: Handle unexpected exceptions :)
                <test-case name="{$case/@name}" result="fail">
                   <exception>Exception while loading expected result fragment: {$util:exception-message}</exception>
                   <query>{$query}</query>
                </test-case>
            )
        (: Comparison method: "Inspect" :)
        (: A text compare is sufficient in many test cases :)
        else if ($output/@compare eq "Inspect") then
            let $text := util:file-read(concat($xqts:XQTS_HOME, "ExpectedTestResults/", $case/@FilePath,
                "/", $output/text()))
            let $test := xqts:normalize-text($text) eq xqts:normalize-text($result)
            return
                xqts:print-result($case/@name, $test, $query, $result, $text, $case)

        (: Don't know how to compare :)
        else
            <error test="{$case/@name}">Unknown comparison method: {$output/@compare}.</error>
};

declare function xqts:run-test-case( $case as element(catalog:test-case)) as item()* {
   let $query := xqts:get-query($case)
   let $context :=
       <static-context>
       {
           for $input in $case/catalog:input-file
           return
               <variable name="{$input/@variable}">{xqts:get-input-value($input)}</variable>
       }
       </static-context>
   let $result :=
       util:catch("java.lang.Exception",
           let $result :=
               util:eval-with-context($query, $context, false())
           return
               xqts:check-output($query, $result, $case),
           if ($case//catalog:expected-error) then
               <test-case name="{$case/@name}" result="pass">
                   <exception>{$util:exception-message}</exception>
                   <expected-error>{$case//catalog:expected-error/text()}</expected-error>
                   <query>{$query}</query>
               </test-case>
           else
               <test-case name="{$case/@name}" result="fail">
                   <exception>{$util:exception-message}</exception>
                   <query>{$query}</query>
               </test-case>
       )
   return $result
};

declare function xqts:finish($result as element()) as empty() {
    let $passed := count($result//test-case[@result = 'pass'])
    let $failed := count($result//test-case[@result = 'fail'])
    return (
        update value $result/@passed with xs:int($passed),
        update value $result/@failed with xs:int($failed)
    )
};

declare function xqts:run-single-test-case($case as element(catalog:test-case),
    $resultRoot as element()?) as empty() {
    let $result := xqts:run-test-case($case)
    return (
        update insert $result into $resultRoot,
        let $added := $resultRoot/test-case[@name = $case/@name]
        return
            if ($added) then xqts:report-progress($added)
            else ()
    )
};

declare function xqts:run-test-group($group as element(catalog:test-group)) as empty() {
    (: Create the collection hierarchy for this group and get the results.xml doc to
        append to. :)
    let $resultsDoc := xqts:create-collections($group)
    let $tests := $group/catalog:test-case[
    	not(starts-with(@name, 'Constr-inscope-10')) and
    	not(starts-with(@name, 'Constr-inscope-11')) and
    	not(starts-with(@name, 'Constr-inscope-12')) and
    	not(starts-with(@name, 'Constr-inscope-13')) and
    	not(starts-with(@name, 'Constr-inscope-14')) and
    	not(starts-with(@name, 'Constr-namespace-22'))
    	]
    return (
        (: Execute the test cases :)
        for $test in $tests
        let $log := util:log("DEBUG", ("Running test case: ", string($test/@name)))
        return
            xqts:run-single-test-case($test, $resultsDoc/test-result),
        if ($tests) then
            xqts:finish($resultsDoc/test-result)
        else
            xdb:remove(util:collection-name($resultsDoc), util:document-name($resultsDoc)),
        (: Execute tests in child groups :)
        for $childGroup in $group/catalog:test-group
        let $log := util:log("DEBUG", ("Entering group: ", string($childGroup/@name)))
        return
            xqts:run-test-group($childGroup)
    )
};

declare function xqts:test-single($name as xs:string) as element() {
    let $test := //catalog:test-case[@name = $name]
    return
        if ($test) then
            let $resultsDoc := xqts:create-collections($test/parent::catalog:test-group)
            let $dummy := xqts:run-single-test-case($test, $resultsDoc/test-result)
            return
                $resultsDoc/test-result
        else
            <error>Test case not found: {$name}.</error>
};

declare function xqts:test-group($groupName as xs:string) as empty() {
    let $group := //catalog:test-group[@name = $groupName]
    return (
        xqts:create-progress-file(count($group//catalog:test-case)),
        xqts:run-test-group($group)
    )
};

declare function xqts:test-all() as empty() {
    for $test in /catalog:test-suite/catalog:test-group
    return
        xqts:test-group($test/@name)
};

declare function xqts:get-input-value($input as element(catalog:input-file)) as item()* {
   if ($input eq "emptydoc") then
       ()
   else (
       let $source := root($input)//catalog:source[@ID = $input/text()]
       return
           if (empty($source)) then
               concat("no input found: ", $input/text())
           else
               doc(concat("/db/XQTS/", $source/@FileName))
   )
};

declare function xqts:overall-result() {
    let $passed := count(//test-case[@result = "pass"])
    let $failed := count(//test-case[@result = "fail"])
    return
        <test-result failed="{$failed}" passed="{$passed}"
            percentage="{$passed div ($passed + $failed)}"/>
};

let $group := request:get-parameter('group', ())
return
    if ($group) then
        xqts:test-group($group)
    else
        ()


Functions cannot be compared

Functions cannot be compared

xquery version "3.1";

(:~
 : Origami tests: node transformers
 :)
module namespace test = 'http://xokomola.com/xquery/origami/tests';

import module namespace λ = 'http://xokomola.com/xquery/origami/λ'
    at '../la.xqm';

(:
 : NOTE: functions cannot be compared so although they
 :       may appear as part of mu nodes.
 :)
declare %unit:test function test:content()
{
    unit:assert-equals(
        ['p'] => λ:content(['x']),
        ['p', ['x']]
    ),
    unit:assert-equals(
        ['p', 'foo'] => λ:content(['x']),
        ['p', ['x']]
    ),
    unit:assert-equals(
        ['p', map { 'a': 1 }, 'foo'] => λ:content(['x']),
        ['p', map { 'a': 1 },['x']]
    )
};

declare %unit:test function test:replace()
{
    unit:assert-equals(
        ['p'] => λ:replace(['x']),
        ['x']
    ),
    unit:assert-equals(
        ['p', 'foo'] => λ:replace(['x']),
        ['x']
    ),
    unit:assert-equals(
        ['p', map { 'a': 1 }, 'foo'] => λ:replace(['x']),
        ['x']
    )
};

declare %unit:test function test:wrap()
{
    unit:assert-equals(
        ['p'] => λ:wrap(['x']),
        ['x', ['p']]
    ),
    unit:assert-equals(
        ['p'] => λ:wrap(['x', map { 'a': 1 }]),
        ['x', map { 'a': 1 }, ['p']]
    ),
    unit:assert-equals(
        ['p'] => λ:wrap(['x', map { 'a': 1 }, 'foo']),
        ['x', map { 'a': 1 }, ['p']]
    ),
    unit:assert-equals(
        ['p'] => λ:wrap(['x', 'foo']),
        ['x', ['p']]
    )
};

xquery version "3.1";

(:~
 : Origami tests: node transformers
 :)
module namespace test = 'http://xokomola.com/xquery/origami/tests';

import module namespace λ = 'http://xokomola.com/xquery/origami/λ'
    at '../la.xqm';

declare %unit:test function test:content()
{
    unit:assert-equals(
        ['p'] => λ:content(['x']),
        ['p', ['x']]
    ),
    unit:assert-equals(
        ['p', 'foo'] => λ:content(['x']),
        ['p', ['x']]
    ),
    unit:assert-equals(
        ['p', map { 'a': 1 }, 'foo'] => λ:content(['x']),
        ['p', map { 'a': 1 },['x']]
    )
};

declare %unit:test function test:replace()
{
    unit:assert-equals(
        ['p'] => λ:replace(['x']),
        ['x']
    ),
    unit:assert-equals(
        ['p', 'foo'] => λ:replace(['x']),
        ['x']
    ),
    unit:assert-equals(
        ['p', map { 'a': 1 }, 'foo'] => λ:replace(['x']),
        ['x']
    )
};

declare %unit:test function test:wrap()
{
    unit:assert-equals(
        ['p'] => λ:wrap(['x']),
        ['x', ['p']]
    ),
    unit:assert-equals(
        ['p'] => λ:wrap(['x', map { 'a': 1 }]),
        ['x', map { 'a': 1 }, ['p']]
    ),
    unit:assert-equals(
        ['p'] => λ:wrap(['x', map { 'a': 1 }, 'foo']),
        ['x', map { 'a': 1 }, ['p']]
    )
};