Xquery code for contract slide , run mlDeploy and call /ext/contract-tranform please make sure that the path is corrected on line #601, this is hardcoded for now

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)
  )


OPEN - issue TRIAD-51: Beta Release of openMDR  https://jira.ctsa.cagrid.org:8443/browse/TRIAD-51

xquery version "1.0";

(: ~
 : Module Name:             new property webpage and XQuery
 :
 : Module Version           2.0
 :
 : Date                     31st July 2007
 :
 : Copyright                The cagrid consortium
 :
 : Module overview          Creates and property and displays list
 :
 :)

(:~
 :    @author Steve Harris
 :    @version 0.1
 :
 :    @author Steve Harris
 :    @version 2.0
 :     now allows searching for concept terms
~ :)

  import module namespace
  lib-forms="http://www.cagrid.org/xquery/library/forms"
  at "../edit/m-lib-forms.xquery";

  import module namespace
  lib-util="http://www.cagrid.org/xquery/library/util"
  at "../library/m-lib-util.xquery";

  import module namespace
  lib-rendering="http://www.cagrid.org/xquery/library/rendering"
  at "../web/m-lib-rendering.xquery";

  import module namespace
  lib-make-admin-item="http://www.cagrid.org/xquery/library/make-admin-item"
  at "../edit/m-lib-make-admin-item.xquery";

declare namespace openMDR = "http://www.cagrid.org/schema/openMDR";
declare namespace ISO11179= "http://www.cagrid.org/schema/ISO11179";
declare namespace session="http://exist-db.org/xquery/session";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace util="http://exist-db.org/xquery/util";

declare function local:property(
   $id as xs:string,
   $reg-auth as xs:string,
   $administrative-note as xs:string,
   $administrative-status as xs:string,
   $administered-by as xs:string,
   $submitted-by as xs:string,
   $registered-by as xs:string,
   $context-ids as xs:string*,
   $country-identifiers as xs:string*,
   $language-identifiers as xs:string*,
   $names as xs:string*,
   $definitions as xs:string*,
   $sources as xs:string*,
   $uri as xs:string?,
   $preferred as xs:string?
   ) as xs:boolean
{
   let $version := lib-forms:substring-after-last($id,'-')
   let $data-identifier := lib-forms:substring-after-last(lib-forms:substring-before-last($id,'-'),'-')
   let $doc-name := concat($id,'.xml')

   let $content := (
            lib-make-admin-item:administration-record($administrative-note,$administrative-status,'Recorded'),
            lib-make-admin-item:custodians($administered-by,$registered-by,$submitted-by),
            lib-make-admin-item:havings(
                    $context-ids,
                    $country-identifiers,
                    $language-identifiers,
                    $names,
                    $definitions,
                    $preferred,
                    $sources),

                  element openMDR:reference_uri {$uri})

   (: compose the document :)
   let $document :=
      element openMDR:Property {
            attribute item_registration_authority_identifier {$reg-auth},
            attribute data_identifier {$data-identifier},
            attribute version {$version},
            $content
           }

   let $collection := 'property'
   let $message := lib-forms:store-document($document)
   return
      if ($message='stored')
      then true()
      else response:redirect-to(xs:anyURI(concat("../web/login.xquery?calling_page=editProperty.xquery&",$message)))
};

declare function local:input-page(
   $message as xs:string?,
   $id as xs:string?,
   $reg-auth as xs:string?,
   $administrative-note  as xs:string?,
   $administrative-status  as xs:string?,
   $administered-by  as xs:string?,
   $submitted-by  as xs:string?,
   $registered-by  as xs:string?,
   $context-ids  as xs:string*,
   $country-identifiers as xs:string*,
   $language-identifiers as xs:string*,
   $names as xs:string*,
   $definitions as xs:string*,
   $sources as xs:string*,
   $property_uri as xs:string?,
   $action as xs:string?,
   $preferred as xs:string?
   ) {
   let $skip-name := substring-after($action,'delete naming entry')
   let $skip-name-index := if ($skip-name>'') then xs:int($skip-name) else 0

   return

                This form will allow you to edit a property in the metadata repository

          <form name="edit_property" action="editProperty.xquery" method="post" class="cagridForm" enctype="multipart/form-data">

                {lib-forms:hidden-element('id',$id)}
                {lib-forms:hidden-element('updating','updating')}

                {lib-forms:edit-admin-item($reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,
                     $action)}

                       Property specific properties

                               uri

                                  {
                                     lib-forms:find-concept-id('property_uri','get concept',$property_uri)
                                  }

	<input type="submit" name="update" value="Store Changes"/>	<input type="submit" name="update" value="Clear"/>

          </form>

{$message}

   };

declare function local:success-page()
{
   let $calling-page := request:get-parameter("calling-page","")
   return

Property modified

Return to maintenance menu

Create another property class

};

declare option exist:serialize "media-type=text/html method=xhtml doctype-public=-//W3C//DTD XHTML 1.0 Transitional//EN doctype-system=http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd";

   session:create(),
   let $id := request:get-parameter('id','')
   let $updating := request:get-parameter('updating','')
   let $title as xs:string := concat("Editing Property ", $id)
   let $element := lib-util:mdrElement("property",$id)
   let $action := request:get-parameter('update','')

   let $ireg-auth := string($element/@item_registration_authority_identifier)
   let $iadministrative-note := string($element//openMDR:administrative_note)
   let $iadministrative-status := string($element//openMDR:administrative_status)
   let $iadministered-by := string($element//openMDR:administered_by)
   let $isubmitted-by := string($element//openMDR:submitted_by)
   let $iregistered-by := string($element//openMDR:registered_by)
   let $icontext-ids := $element//openMDR:context_identifier
   let $icountry-identifiers := $element//openMDR:country_identifier
   let $ilanguage-identifiers := $element//openMDR:language_identifier
   let $inames := $element//openMDR:name
   let $idefinitions := $element//openMDR:definition_text
   let $isources := $element//openMDR:definition_source_reference
   let $iproperty_uri := string($element//openMDR:reference_uri)
   let $ipreferred := string(fn:index-of($element//openMDR:preferred_designation,'true'))

   let $reg-auth := request:get-parameter('registration-authority','')
   let $administrative-note := request:get-parameter('administrative-note','')
   let $administrative-status := request:get-parameter('administrative-status','')
   let $administered-by := request:get-parameter('administered-by','')
   let $submitted-by := request:get-parameter('submitted-by','')
   let $registered-by := request:get-parameter('registered-by','')
   let $context-ids := request:get-parameter('context-ids',())
   let $country-identifiers := request:get-parameter('country-identifiers',())
   let $language-identifiers := request:get-parameter('language-identifiers',())
   let $names := request:get-parameter('names',())
   let $definitions := request:get-parameter('definitions',())
   let $sources := request:get-parameter('sources',())
   let $property_uri := request:get-parameter('property_uri','')
   let $preferred := request:get-parameter('preferred','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store Changes')
      then
         (
         if (
               local:property
                  (
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $preferred
                  )
            )
         then (local:success-page()  )
         else (local:input-page(
            'could not store document',
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $action,
                     $preferred
                  )
               )
         )
      else (
         if ($updating ='updating')
         then (
      local:input-page
               (
               '',
               $id,
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $property_uri,
               $action,
               $preferred
               )
         ) else (
               local:input-page
               (
               '',
               $id,
               $ireg-auth,
               $iadministrative-note,
               $iadministrative-status,
               $iadministered-by,
               $isubmitted-by,
               $iregistered-by,
               $icontext-ids,
               $icountry-identifiers,
               $ilanguage-identifiers,
               $inames,
               $idefinitions,
               $isources,
               $iproperty_uri,
               $action,
               $ipreferred
               )
         )
       )

    )

xquery version "1.0";

(: ~
 : Module Name:             new property webpage and XQuery
 :
 : Module Version           2.0
 :
 : Date                     31st July 2007
 :
 : Copyright                The cagrid consortium
 :
 : Module overview          Creates and property and displays list
 :
 :)

(:~
 :    @author Steve Harris
 :    @version 0.1
 :
 :    @author Steve Harris
 :    @version 2.0
 :     now allows searching for concept terms
~ :)

  import module namespace
  lib-forms="http://www.cagrid.org/xquery/library/forms"
  at "../edit/m-lib-forms.xquery";

  import module namespace
  lib-util="http://www.cagrid.org/xquery/library/util"
  at "../library/m-lib-util.xquery";

  import module namespace
  lib-rendering="http://www.cagrid.org/xquery/library/rendering"
  at "../web/m-lib-rendering.xquery";

  import module namespace
  lib-make-admin-item="http://www.cagrid.org/xquery/library/make-admin-item"
  at "../edit/m-lib-make-admin-item.xquery";

declare namespace openMDR = "http://www.cagrid.org/schema/openMDR";
declare namespace ISO11179= "http://www.cagrid.org/schema/ISO11179";
declare namespace session="http://exist-db.org/xquery/session";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace exist = "http://exist.sourceforge.net/NS/exist";

declare function local:property(
   $id as xs:string,
   $reg-auth as xs:string,
   $administrative-note as xs:string,
   $administrative-status as xs:string,
   $administered-by as xs:string,
   $submitted-by as xs:string,
   $registered-by as xs:string,
   $context-ids as xs:string*,
   $country-identifiers as xs:string*,
   $language-identifiers as xs:string*,
   $names as xs:string*,
   $definitions as xs:string*,
   $sources as xs:string*,
   $uri as xs:string?,
   $preferred as xs:string?
   ) as xs:boolean
{
   let $version := lib-forms:substring-after-last($id,'-')
   let $data-identifier := lib-forms:substring-after-last(lib-forms:substring-before-last($id,'-'),'-')
   let $doc-name := concat($id,'.xml')

   let $content := (
            lib-make-admin-item:administration-record($administrative-note,$administrative-status,'Recorded'),
            lib-make-admin-item:custodians($administered-by,$registered-by,$submitted-by),
            lib-make-admin-item:havings(
                    $context-ids,
                    $country-identifiers,
                    $language-identifiers,
                    $names,
                    $definitions,
                    $preferred,
                    $sources),

                  element openMDR:reference_uri {$uri})

   (: compose the document :)
   let $document :=
      element openMDR:Property {
            attribute item_registration_authority_identifier {$reg-auth},
            attribute data_identifier {$data-identifier},
            attribute version {$version},
            $content
           }

   let $collection := 'property'
   let $message := lib-forms:store-document($document)
   return
      if ($message='stored')
      then true()
      else response:redirect-to(xs:anyURI(concat("../web/login.xquery?calling_page=editProperty.xquery&",$message)))
};

declare function local:input-page(
   $message as xs:string?,
   $id as xs:string?,
   $reg-auth as xs:string?,
   $administrative-note  as xs:string?,
   $administrative-status  as xs:string?,
   $administered-by  as xs:string?,
   $submitted-by  as xs:string?,
   $registered-by  as xs:string?,
   $context-ids  as xs:string*,
   $country-identifiers as xs:string*,
   $language-identifiers as xs:string*,
   $names as xs:string*,
   $definitions as xs:string*,
   $sources as xs:string*,
   $property_uri as xs:string?,
   $action as xs:string?,
   $preferred as xs:string?
   ) {
   let $skip-name := substring-after($action,'delete naming entry')
   let $skip-name-index := if ($skip-name>'') then xs:int($skip-name) else 0

   return

                This form will allow you to edit a property in the metadata repository

          <form name="edit_property" action="editProperty.xquery" method="post" class="cagridForm" enctype="multipart/form-data">

                {lib-forms:hidden-element('id',$id)}
                {lib-forms:hidden-element('updating','updating')}

                {lib-forms:edit-admin-item($reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,
                     $action)}

                       Property specific properties

                               uri

                                  {
                                     lib-forms:find-concept-id('property_uri','get concept',$property_uri)
                                  }

	<input type="submit" name="update" value="Store Changes"/>	<input type="submit" name="update" value="Clear"/>

          </form>

{$message}

   };

declare function local:success-page()
{
   let $calling-page := request:get-parameter("calling-page","")
   return

Property modified

Return to maintenance menu

Create another property class

};

declare option exist:serialize "media-type=text/html method=xhtml doctype-public=-//W3C//DTD XHTML 1.0 Transitional//EN doctype-system=http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd";

   session:create(),
   let $id := request:get-parameter('id','')
   let $updating := request:get-parameter('updating','')
   let $title as xs:string := concat("Editing Property ", $id)
   let $element := lib-util:mdrElement("property",$id)
   let $action := request:get-parameter('update','')

   let $ireg-auth := string($element/@item_registration_authority_identifier)
   let $iadministrative-note := string($element//openMDR:administrative_note)
   let $iadministrative-status := string($element//openMDR:administrative_status)
   let $iadministered-by := string($element//openMDR:administered_by)
   let $isubmitted-by := string($element//openMDR:submitted_by)
   let $iregistered-by := string($element//openMDR:registered_by)
   let $icontext-ids := $element//openMDR:context_identifier
   let $icountry-identifiers := $element//openMDR:country_identifier
   let $ilanguage-identifiers := $element//openMDR:language_identifier
   let $inames := $element//openMDR:name
   let $idefinitions := $element//openMDR:definition_text
   let $isources := $element//openMDR:definition_source_reference
   let $iproperty_uri := string($element//openMDR:reference_uri)
   let $ipreferred := fn:index-of($element//openMDR:preferred_designation,'true')

   let $reg-auth := request:get-parameter('registration-authority','')
   let $administrative-note := request:get-parameter('administrative-note','')
   let $administrative-status := request:get-parameter('administrative-status','')
   let $administered-by := request:get-parameter('administered-by','')
   let $submitted-by := request:get-parameter('submitted-by','')
   let $registered-by := request:get-parameter('registered-by','')
   let $context-ids := request:get-parameter('context-ids',())
   let $country-identifiers := request:get-parameter('country-identifiers',())
   let $language-identifiers := request:get-parameter('language-identifiers',())
   let $names := request:get-parameter('names',())
   let $definitions := request:get-parameter('definitions',())
   let $sources := request:get-parameter('sources',())
   let $property_uri := request:get-parameter('property_uri','')
   let $preferred := request:get-parameter('preferred','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store Changes')
      then
         (
         if (
               local:property
                  (
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $preferred
                  )
            )
         then (local:success-page()  )
         else (local:input-page(
            'could not store document',
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $action,
                     $preferred
                  )
               )
         )
      else (
         if ($updating ='updating')
         then (
      local:input-page
               (
               '',
               $id,
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $property_uri,
               $action,
               $preferred
               )
         ) else (
               local:input-page
               (
               '',
               $id,
               $ireg-auth,
               $iadministrative-note,
               $iadministrative-status,
               $iadministered-by,
               $isubmitted-by,
               $iregistered-by,
               $icontext-ids,
               $icountry-identifiers,
               $ilanguage-identifiers,
               $inames,
               $idefinitions,
               $isources,
               $iproperty_uri,
               $action,
               $ipreferred
               )
         )
       )

    )