[test] expand simple map operator testsuite

refs #1655
refs #3491

(:
 : eXist-db Open Source Native XML Database
 : Copyright (C) 2001 The eXist-db Authors
 :
 : info@exist-db.org
 : http://www.exist-db.org
 :
 : This library is free software; you can redistribute it and/or
 : modify it under the terms of the GNU Lesser General Public
 : License as published by the Free Software Foundation; either
 : version 2.1 of the License, or (at your option) any later version.
 :
 : This library is distributed in the hope that it will be useful,
 : but WITHOUT ANY WARRANTY; without even the implied warranty of
 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 : Lesser General Public License for more details.
 :
 : You should have received a copy of the GNU Lesser General Public
 : License along with this library; if not, write to the Free Software
 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 :)
xquery version "3.1";

module namespace bang="http://exist-db.org/xquery/test/bang";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $bang:works :=
    <works>
        <employee name="Jane Doe 1" gender="female">
            <empnum>E1</empnum>
            <pnum>P1</pnum>
            <hours>40</hours>
        </employee>
        <employee name = "John Doe 2" gender="male">
            <empnum>E1</empnum>
            <pnum>P2</pnum>
            <hours>70</hours>
            <hours>20</hours>Text data from Employee[2]
        </employee>
        <employee name = "Jane Doe 3" gender="female">
            <empnum>E1</empnum>
            <pnum>P3</pnum>
            <hours>80</hours>
        </employee>
        <employee name= "John Doe 4" gender="male">
            <empnum>E1</empnum>
            <pnum>P4</pnum>
            <hours>20</hours>
            <hours>40</hours>
        </employee>
    </works>;

declare
    %test:assertEquals(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
function bang:numbers1() {
    (1 to 10)!(.*.)
};

declare
    %test:assertEquals(3, 4, 5)
function bang:functions1() {
    ("red", "blue", "green")!string-length()
};

declare
    %test:assertEquals(4, 5, 6)
function bang:functions2() {
    ("red", "blue", "green") ! string-length() ! (.+1)
};

declare
    %test:assertEquals("RED", "BLUE", "GREEN")
function bang:functions3() {
    ("red", "blue", "green") ! upper-case(.)
};

declare
    %test:assertEquals("RED", "BLUE", "GREEN")
function bang:functions4() {
    ("red", "blue", "green") ! bang:upper-case(.)
};

declare %private function bang:upper-case($str as xs:string) {
    upper-case($str)
};

declare
    %test:assertEquals(1, 2, 3)
function bang:position1() {
    ("red", "blue", "green")!position()
};

declare
    %test:assertEquals("false", "false", "true")
function bang:position2() {
    ("red", "blue", "green")!(position() = last())
};

declare
    %test:assertEquals(1, 1, 2, 1, 2, 3)
function bang:position3() {
    (1 to 3) ! ((1 to .) ! position())
};

declare
    %test:assertEquals(3, 3, 3)
function bang:position4() {
    ("red", "blue", "green")!last()
};

declare
    %test:assertEquals("false", "false", "false", "true")
function bang:position5() {
    $bang:works/employee ! (position() = last())
};

declare
    %test:assertEquals("John Doe 2", "Jane Doe 1", "John Doe 2")
function bang:nodes1() {
    ($bang:works/employee[2], $bang:works/employee[1], $bang:works/employee[2]) ! @name ! string()
};

declare
    %test:assertEquals(20)
function bang:nodes2() {
    $bang:works ! employee[2] ! hours[2] ! number()
};

declare
    %test:assertEquals("-18")
function bang:precedence1() {
    2 + ($bang:works ! employee[2] ! hours[2]) ! number() ! (-.)
};

declare
    %test:assertEquals("-3")
function bang:precedence2() {
    -2!(.+1)
};

declare
    %test:assertEquals(1, 1, 2, 1, 2, 3)
function bang:sequence() {
    (1 to 3) ! (1 to .)
};

declare
    %test:assertEquals(4)
function bang:nodepath() {
    count($bang:works ! employee)
};

declare
    %test:assertEquals("John Doe 4")
function bang:nodepath-reverse() {
    $bang:works/employee/pnum[. = "P4"] ! ancestor::employee ! @name ! string()
};

declare
    %test:assertEquals("<name>John Doe 4</name>")
function bang:constructor() {
    $bang:works/employee[pnum = "P4"] ! <name>{@name/string()}</name>
};

declare
    %test:assertEquals("a", "b", "c")
function bang:implicit-context() {
    document { <c/> } ! //* ! local-name(.)
};

declare
    %test:assertEquals(4)
function bang:right-string-length-context-item() {
    1234 ! string-length()
};

(:~
 : See: https://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201906/msg00021.html
 : See: https://github.com/eXist-db/exist/issues/2798
 :)
declare
    %test:assertError("XPTY0004")
function bang:right-string-length() {
    1234 ! string-length(.)
};

declare
    %test:assertEquals(1)
function bang:attribute-left-number-context-item-right() {
    <emp id='1'/>/@id ! number()
};

declare
    %test:assertEquals(1)
function bang:attribute-left-number-right() {
    <emp id='1'/>/@id ! number(.)
};

declare
    %test:assertEquals(1)
function bang:element-left-number-attribute-right() {
    <emp id='1'/> ! number(@id)
};

declare
    %test:assertEquals(1,2,3)
function bang:map-get () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! map:get(., 'a')
};

declare
    %test:assertEquals(1,2,3)
function bang:array-get () {
    ([1], [2], [3]) ! array:get(., 1)
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-context-item () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! .?a
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-parenthesized () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! (.?a)
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-parenthesized-context-item () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! (.)?a
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-standard () {
    ([1], [2], [3]) ! .?1
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-parenthesized () {
    ([1], [2], [3]) ! (.?1)
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-parenthesized-context-item () {
    ([1], [2], [3]) ! (.)?1
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! .(1)
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call-parenthesized () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! (.(1))
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call-parenthesized-context-item () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! (.)(1)
};

(: https://github.com/eXist-db/exist/issues/1655 :)
declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-implicit-context () {
    ([1], [2], [3]) ! ?1
};

(: https://github.com/eXist-db/exist/issues/1655 :)
declare
    %test:assertEquals(1,2,3)
function bang:map-lookup-implicit-context () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! ?a
};

(: https://github.com/eXist-db/exist/issues/3491 :)
declare
    %test:assertEquals(3,4,5)
function bang:map-lookup-implicit-context-as-argument () {
    (map {'a': (1,2)}, map {'a': (2,2)}, map {'a':(2,3)}) ! sum(?a)
};

(: https://github.com/eXist-db/exist/issues/3491 :)
declare
    %test:assertEquals("1|2|3", "a|b|c")
function bang:array-to-sequence-as-parameter () {
    ([1,2,3], ['a', 'b', 'c'])
      ! string-join(?*, '|')
};

(:
 : eXist-db Open Source Native XML Database
 : Copyright (C) 2001 The eXist-db Authors
 :
 : info@exist-db.org
 : http://www.exist-db.org
 :
 : This library is free software; you can redistribute it and/or
 : modify it under the terms of the GNU Lesser General Public
 : License as published by the Free Software Foundation; either
 : version 2.1 of the License, or (at your option) any later version.
 :
 : This library is distributed in the hope that it will be useful,
 : but WITHOUT ANY WARRANTY; without even the implied warranty of
 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 : Lesser General Public License for more details.
 :
 : You should have received a copy of the GNU Lesser General Public
 : License along with this library; if not, write to the Free Software
 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 :)
xquery version "3.1";

module namespace bang="http://exist-db.org/xquery/test/bang";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $bang:works :=
    <works>
        <employee name="Jane Doe 1" gender="female">
            <empnum>E1</empnum>
            <pnum>P1</pnum>
            <hours>40</hours>
        </employee>
        <employee name = "John Doe 2" gender="male">
            <empnum>E1</empnum>
            <pnum>P2</pnum>
            <hours>70</hours>
            <hours>20</hours>Text data from Employee[2]
        </employee>
        <employee name = "Jane Doe 3" gender="female">
            <empnum>E1</empnum>
            <pnum>P3</pnum>
            <hours>80</hours>
        </employee>
        <employee name= "John Doe 4" gender="male">
            <empnum>E1</empnum>
            <pnum>P4</pnum>
            <hours>20</hours>
            <hours>40</hours>
        </employee>
    </works>;

declare
    %test:assertEquals(1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
function bang:numbers1() {
    (1 to 10)!(.*.)
};

declare
    %test:assertEquals(3, 4, 5)
function bang:functions1() {
    ("red", "blue", "green")!string-length()
};

declare
    %test:assertEquals(4, 5, 6)
function bang:functions2() {
    ("red", "blue", "green") ! string-length() ! (.+1)
};

declare
    %test:assertEquals("RED", "BLUE", "GREEN")
function bang:functions3() {
    ("red", "blue", "green") ! upper-case(.)
};

declare
    %test:assertEquals("RED", "BLUE", "GREEN")
function bang:functions4() {
    ("red", "blue", "green") ! bang:upper-case(.)
};

declare %private function bang:upper-case($str as xs:string) {
    upper-case($str)
};

declare
    %test:assertEquals(1, 2, 3)
function bang:position1() {
    ("red", "blue", "green")!position()
};

declare
    %test:assertEquals("false", "false", "true")
function bang:position2() {
    ("red", "blue", "green")!(position() = last())
};

declare
    %test:assertEquals(1, 1, 2, 1, 2, 3)
function bang:position3() {
    (1 to 3) ! ((1 to .) ! position())
};

declare
    %test:assertEquals(3, 3, 3)
function bang:position4() {
    ("red", "blue", "green")!last()
};

declare
    %test:assertEquals("false", "false", "false", "true")
function bang:position5() {
    $bang:works/employee ! (position() = last())
};

declare
    %test:assertEquals("John Doe 2", "Jane Doe 1", "John Doe 2")
function bang:nodes1() {
    ($bang:works/employee[2], $bang:works/employee[1], $bang:works/employee[2]) ! @name ! string()
};

declare
    %test:assertEquals(20)
function bang:nodes2() {
    $bang:works ! employee[2] ! hours[2] ! number()
};

declare
    %test:assertEquals("-18")
function bang:precedence1() {
    2 + ($bang:works ! employee[2] ! hours[2]) ! number() ! (-.)
};

declare
    %test:assertEquals("-3")
function bang:precedence2() {
    -2!(.+1)
};

declare
    %test:assertEquals(1, 1, 2, 1, 2, 3)
function bang:sequence() {
    (1 to 3) ! (1 to .)
};

declare
    %test:assertEquals(4)
function bang:nodepath() {
    count($bang:works ! employee)
};

declare
    %test:assertEquals("John Doe 4")
function bang:nodepath-reverse() {
    $bang:works/employee/pnum[. = "P4"] ! ancestor::employee ! @name ! string()
};

declare
    %test:assertEquals("<name>John Doe 4</name>")
function bang:constructor() {
    $bang:works/employee[pnum = "P4"] ! <name>{@name/string()}</name>
};

declare
    %test:assertEquals("a", "b", "c")
function bang:implicit-context() {
    document { <c/> } ! //* ! local-name(.)
};

declare
    %test:assertEquals(4)
function bang:right-string-length-context-item() {
    1234 ! string-length()
};

(:~
 : See: https://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201906/msg00021.html
 : See: https://github.com/eXist-db/exist/issues/2798
 :)
declare
    %test:assertError("XPTY0004")
function bang:right-string-length() {
    1234 ! string-length(.)
};

declare
    %test:assertEquals(1)
function bang:attribute-left-number-context-item-right() {
    <emp id='1'/>/@id ! number()
};

declare
    %test:assertEquals(1)
function bang:attribute-left-number-right() {
    <emp id='1'/>/@id ! number(.)
};

declare
    %test:assertEquals(1)
function bang:element-left-number-attribute-right() {
    <emp id='1'/> ! number(@id)
};

declare
    %test:assertEquals(1,2,3)
function bang:map-get () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! map:get(., 'a')
};

declare
    %test:assertEquals(1,2,3)
function bang:array-get () {
    ([1], [2], [3]) ! array:get(., 1)
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-context-item () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! .?a
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-parenthesized () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! (.?a)
};

declare
     %test:assertEquals(1,2,3)
function bang:map-lookup-parenthesized-context-item () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! (.)?a
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-standard () {
    ([1], [2], [3]) ! .?1
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-parenthesized () {
    ([1], [2], [3]) ! (.?1)
};

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-parenthesized-context-item () {
    ([1], [2], [3]) ! (.)?1
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! .(1)
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call-parenthesized () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! (.(1))
};

declare
    %test:assertEquals(1,1,1,1,1)
function bang:mixed-function-types-call-parenthesized-context-item () {
    let $id := function ($a) { $a }
    return (function ($a) {1}, $id, sum#1, [1], map{1:1}) ! (.)(1)
};

(:~
 : parse error needs to be fixed first
 : https://github.com/eXist-db/exist/issues/1655

declare
    %test:assertEquals(1,2,3)
function bang:array-lookup-implicit-context () {
    ([1], [2], [3]) ! ?1
};

declare
    %test:assertEquals(1,2,3)
function bang:map-lookup-implicit-context () {
    (map {'a':1}, map {'a':2}, map {'a':3}) ! ?a
};

 :)


Remove license from default layout

Remove license from default layout

xquery version "1.0" encoding "utf-8";

import module namespace calli = "http://callimachusproject.org/rdf/2009/framework#" at "/callimachus/layout-functions.xq";

    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,target-densityDpi=device-dpi"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" href="/favicon.ico" />
    {calli:styles-href(<link rel="stylesheet" />)}
    {calli:scripts-src(
    <![endif]-->
    {calli:head-nodes()}

    {calli:body-attributes()}

                        {calli:home-href(Callimachus)}

                        {calli:login-href(Sign in )}

{calli:lookup-form('Lookup...')}

                            <button type="button" class="btn btn-default navbar-btn dropdown-toggle" data-toggle="dropdown">
                                Main menu

                            </button>

{calli:folder-href(Home folder)}

{calli:changes-href(Recent changes)}

{calli:lookup-href(Lookup resources)}

{calli:callimachus-about-href(About Callimachus)}

{calli:callimachus-getting-started-href(Getting started)}

{calli:callimachus-feedback-href(Send feedback)}

                                {calli:head-links(

,
)}

{calli:whatlinkshere-href(What links here)}

{calli:relatedchanges-href(Related changes)}

{calli:permissions-href(Permissions)}

{calli:introspect-href(Introspect resource)}

Print this page

{calli:profile-href(Account)}

{calli:logout-href(Sign out)}

{calli:breadcrumb-links(

,
)}

            {calli:activate-nav(

{calli:view-href(View)}

{calli:edit-href(Edit)}

{calli:discussion-href(Discussion)}

{calli:describe-href(Describe)}

{calli:history-href(History)}

            )}
            {calli:error-alert(

                <button type="button" class="close" data-dismiss="alert">×</button>

Oops!

)}

        {calli:body-nodes()}

                {calli:generator-p(
)}
                {calli:lastmod-time(
This resource was last modified at <time class="datetime-local"/>
)}

xquery version "1.0" encoding "utf-8";
(:
 : Copyright (c) 2014 3 Round Stones Inc., Some Rights Reserved
 :
 : Licensed under the Apache License, Version 2.0 (the "License");
 : you may not use this file except in compliance with the License.
 : You may obtain a copy of the License at
 :
 :     http://www.apache.org/licenses/LICENSE-2.0
 :
 : Unless required by applicable law or agreed to in writing, software
 : distributed under the License is distributed on an "AS IS" BASIS,
 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 : See the License for the specific language governing permissions and
 : limitations under the License.
 :
 :)

import module namespace calli = "http://callimachusproject.org/rdf/2009/framework#" at "/callimachus/layout-functions.xq";

    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,target-densityDpi=device-dpi"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" href="/favicon.ico" />
    {calli:styles-href(<link rel="stylesheet" />)}
    {calli:scripts-src(
    <![endif]-->
    {calli:head-nodes()}

    {calli:body-attributes()}

                        {calli:home-href(Callimachus)}

                        {calli:login-href(Sign in )}

{calli:lookup-form('Lookup...')}

                            <button type="button" class="btn btn-default navbar-btn dropdown-toggle" data-toggle="dropdown">
                                Main menu

                            </button>

{calli:folder-href(Home folder)}

{calli:changes-href(Recent changes)}

{calli:lookup-href(Lookup resources)}

{calli:callimachus-about-href(About Callimachus)}

{calli:callimachus-getting-started-href(Getting started)}

{calli:callimachus-feedback-href(Send feedback)}

                                {calli:head-links(

,
)}

{calli:whatlinkshere-href(What links here)}

{calli:relatedchanges-href(Related changes)}

{calli:permissions-href(Permissions)}

{calli:introspect-href(Introspect resource)}

Print this page

{calli:profile-href(Account)}

{calli:logout-href(Sign out)}

{calli:breadcrumb-links(

,
)}

            {calli:activate-nav(

{calli:view-href(View)}

{calli:edit-href(Edit)}

{calli:discussion-href(Discussion)}

{calli:describe-href(Describe)}

{calli:history-href(History)}

            )}
            {calli:error-alert(

                <button type="button" class="close" data-dismiss="alert">×</button>

Oops!

)}

        {calli:body-nodes()}

                {calli:generator-p(
)}
                {calli:lastmod-time(
This resource was last modified at <time class="datetime-local"/>
)}


fixing

fixing

xquery version "1.0";

(: ~
 : Module Name:             new conceptual domain webpage and XQuery
 :
 : Module overview          Creates a new Organization
 :)

(:~
 :    @author Rakesh Dhaval
 :    @version 0.1
~ :)

  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:organisation(
   $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*,
   $preferred as xs:string?,

   $organization_name as xs:string?,
   $organization_mail_address as xs:string?,
   $contact_name as xs:string?,
   $contact_title as xs:string?,
   $contact_information as xs:string?

   ) as xs:boolean
{
   let $version := '0.1'
   let $data-identifier := lib-forms:generate-id()
   let $new-identifier := concat($reg-auth, '-', $data-identifier, '-', $version)
   let $doc-name := concat($new-identifier,'.xml')

	 let $organization-identifier := lib-forms:generate-id()
	 let $contact-identifier := lib-forms:generate-id()

   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)

    )

   (: compose the document :)
   let $document :=
            element openMDR:Organization {
     										attribute organization_identifier{$organization-identifier},
           							        element openMDR:organization_name{$organization_name},
                							element openMDR:organization_mail_address{$organization_mail_address},
                							element openMDR:Contact {
    							            attribute contact_identifier{$contact-identifier},
    							            element openMDR:contact_name{$contact_name},
    							            element openMDR:contact_title{$contact_title},
    							            element openMDR:contact_information{$contact_information}
    							            }
							             }

   let $collection := 'organisation'
   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=newOrganisation.xquery&",$message)))
};

declare function local:input-page(
   $message 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*,
   $preferred as xs:string?,

   $org_name as xs:string?,
   $org_mail_address as xs:string?,
   $contact-name as xs:string?,
   $contact-title as xs:string?,
   $contact-information as xs:string?,
   $action 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 create a new Organisation in the metadata repository

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

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

Organization

                {

                  	Organization Name
                    <input type="text" name="org_name"></input>

,

                  	Organization Email Address
                    <input type="text" name="org_mail_address"></input>

              	}

Contact

                {

                  	Name
                    <input type="text" name="contact-name"></input>

,

                  	Title
                    <input type="text" name="contact-title"></input>

,

                  	Information
                    <input type="text" name="contact-information"></input>

              	}

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

          </form>

{$message}

   };

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

Organization created

Return to maintenance menu

Create another Organization

};

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 $title as xs:string := "Creating a New Organisation"
   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 $preferred := request:get-parameter('preferred','')

   let $organization_name :=request:get-parameter('org_name','')
   let $organization_mail_address :=request:get-parameter('org_mail_address','')
   let $contact_name :=request:get-parameter('contact-name','')
   let $contact_title :=request:get-parameter('contact-title','')
   let $contact_information :=request:get-parameter('contact-information','')
   let $action := request:get-parameter('update','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store')
      then
         (
         if (
               local:organisation
                  (
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,

                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,

                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
            )
         then local:success-page()
         else (local:input-page(
            'could not store document',
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,

                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,

                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information,
                     $action
                  )
               )
         )
          else local:input-page(
                     '',
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,

                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,

                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information,
                     $action
                  )
         )

xquery version "1.0";

(: ~
 : Module Name:             new conceptual domain webpage and XQuery
 :
 : Module overview          Creates a new Organization
 :)

(:~
 :    @author Rakesh Dhaval
 :    @version 0.1
~ :)

  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:organisation(
   $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*,
   $preferred as xs:string?,
   $organization_name as xs:string?,
   $organization_mail_address as xs:string?,
   $contact_information as xs:string?,
   $contact_name as xs:string?,
   $contact_title as xs:string?

   ) as xs:boolean
{
   let $version := '0.1'
   let $data-identifier := lib-forms:generate-id()
   let $new-identifier := concat($reg-auth, '-', $data-identifier, '-', $version)
   let $doc-name := concat($new-identifier,'.xml')

	 let $organization-identifier := lib-forms:generate-id()
	 let $contact-identifier := lib-forms:generate-id()

   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)

    )

   (: compose the document :)
   let $document :=
            element openMDR:Organization {
     										attribute organization_identifier{$organization-identifier},
           							        element openMDR:organization_name{$organization_name},
                							element openMDR:organization_mail_address{$organization_mail_address},
                							element openMDR:Contact {
    							            attribute contact_identifier{$contact-identifier},
    							            element openMDR:contact_name{$contact_name},
    							            element openMDR:contact_title{$contact_title},
    							            element openMDR:contact_information{$contact_information}
    							            }
							             }

   let $collection := 'organisation'
   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=newOrganisation.xquery&",$message)))
};

declare function local:input-page(
   $message 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*,
   $action as xs:string?,
   $preferred as xs:string?,
   $org_name as xs:string?,
   $org_mail_address as xs:string?,
   $contact-name as xs:string?,
   $contact-title as xs:string?,
   $contact-information 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 create a new Organisation in the metadata repository

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

             {lib-forms:edit-admin-item($reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $action)}

Organization

                {

                  	Organization Name
                    <input type="text" name="org_name"></input>

,

                  	Organization Email Address
                    <input type="text" name="org_mail_address"></input>

              	}

Contact

                {

                  	Name
                    <input type="text" name="contact-name"></input>

,

                  	Title
                    <input type="text" name="contact-title"></input>

,

                  	Information
                    <input type="text" name="contact-information"></input>

              	}

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

          </form>

{$message}

   };

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

Organization created

Return to maintenance menu

Create another Organization

};

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 $title as xs:string := "Creating a New Organisation"
   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 $preferred := request:get-parameter('preferred','')
   :)
   let $action := request:get-parameter('update','')
   let $organization_name :=request:get-parameter('org_name','')
   let $organization_mail_address :=request:get-parameter('org_mail_address','')
   let $contact_information :=request:get-parameter('contact-information','')
   let $contact_name :=request:get-parameter('contact-name','')
   let $contact_title :=request:get-parameter('contact-title','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store')
      then
         (
         if (
               local:organisation
                  (
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
            )
         then local:success-page()
         else (local:input-page(
            'could not store document',
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $action,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
               )
         )
      else local:input-page
           (
               '',
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $action,
               $preferred,
               $organization_name,
               $organization_mail_address,
							 $contact_name,
               $contact_title,
               $contact_information
               )
         )


minor formatting changes

minor formatting changes

xquery version "1.0";

(: ~
 : Module Name:             new conceptual domain webpage and XQuery
 :
 : Module overview          Creates a new Organization
 :)

(:~
 :    @author Rakesh Dhaval
 :    @version 0.1
~ :)

  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:organisation(
   $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*,
   $preferred as xs:string?,
   $organization_name as xs:string?,
   $organization_mail_address as xs:string?,
   $contact_information as xs:string?,
   $contact_name as xs:string?,
   $contact_title as xs:string?

   ) as xs:boolean
{
   let $version := '0.1'
   let $data-identifier := lib-forms:generate-id()
   let $new-identifier := concat($reg-auth, '-', $data-identifier, '-', $version)
   let $doc-name := concat($new-identifier,'.xml')

	 let $organization-identifier := lib-forms:generate-id()
	 let $contact-identifier := lib-forms:generate-id()

   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)

    )

   (: compose the document :)
   let $document :=
            element openMDR:Organization {
     										attribute organization_identifier{$organization-identifier},
           							        element openMDR:organization_name{$organization_name},
                							element openMDR:organization_mail_address{$organization_mail_address},
                							element openMDR:Contact {
    							            attribute contact_identifier{$contact-identifier},
    							            element openMDR:contact_name{$contact_name},
    							            element openMDR:contact_title{$contact_title},
    							            element openMDR:contact_information{$contact_information}
    							            }
							             }

   let $collection := 'organisation'
   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=newOrganisation.xquery&",$message)))
};

declare function local:input-page(
   $message 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*,
   $action as xs:string?,
   $preferred as xs:string?,
   $org_name as xs:string?,
   $org_mail_address as xs:string?,
   $contact-name as xs:string?,
   $contact-title as xs:string?,
   $contact-information 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 create a new Organisation in the metadata repository

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

             {lib-forms:edit-admin-item($reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $action)}

Organization

                {

                  	Organization Name
                    <input type="text" name="org_name"></input>

,

                  	Organization Email Address
                    <input type="text" name="org_mail_address"></input>

              	}

Contact

                {

                  	Name
                    <input type="text" name="contact-name"></input>

,

                  	Title
                    <input type="text" name="contact-title"></input>

,

                  	Information
                    <input type="text" name="contact-information"></input>

              	}

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

          </form>

{$message}

   };

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

Organization created

Return to maintenance menu

Create another Organization

};

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 $title as xs:string := "Creating a New Organisation"
   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 $preferred := request:get-parameter('preferred','')
   :)
   let $action := request:get-parameter('update','')
   let $organization_name :=request:get-parameter('org_name','')
   let $organization_mail_address :=request:get-parameter('org_mail_address','')
   let $contact_information :=request:get-parameter('contact-information','')
   let $contact_name :=request:get-parameter('contact-name','')
   let $contact_title :=request:get-parameter('contact-title','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store')
      then
         (
         if (
               local:organisation
                  (
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
            )
         then local:success-page()
         else (local:input-page(
            'could not store document',
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $action,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
               )
         )
      else local:input-page
           (
               '',
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $action,
               $preferred,
               $organization_name,
               $organization_mail_address,
							 $contact_name,
               $contact_title,
               $contact_information
               )
         )

xquery version "1.0";

(: ~
 : Module Name:             new conceptual domain webpage and XQuery
 :
 : Module overview          Creates a new Organization
 :)

(:~
 :    @author Rakesh Dhaval
 :    @version 0.1
~ :)

  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:organisation(
   $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*,
   $preferred as xs:string?,
   $organization_name as xs:string?,
   $organization_mail_address as xs:string?,
   $contact_information as xs:string?,
   $contact_name as xs:string?,
   $contact_title as xs:string?

   ) as xs:boolean
{
   let $version := '0.1'
   let $data-identifier := lib-forms:generate-id()
   let $new-identifier := concat($reg-auth, '-', $data-identifier, '-', $version)
   let $doc-name := concat($new-identifier,'.xml')

	 let $organization-identifier := lib-forms:generate-id()
	 let $contact-identifier := lib-forms:generate-id()

   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)

    )

   (: compose the document :)
   let $document :=
            element openMDR:Organization {
     										attribute organization_identifier{$organization-identifier},
           							        element openMDR:organization_name{$organization_name},
                							element openMDR:organization_mail_address{$organization_mail_address},
                							element openMDR:Contact {
    							            attribute contact_identifier{$contact-identifier},
    							            element openMDR:contact_name{$contact_name},
    							            element openMDR:contact_title{$contact_title},
    							            element openMDR:contact_information{$contact_information}
    							            }
							             }

   let $collection := 'organisation'
   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=newOrganisation.xquery&",$message)))
};

declare function local:input-page(
   $message 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*,
   $action as xs:string?,
   $preferred as xs:string?,
   $org_name as xs:string?,
   $org_mail_address as xs:string?,
   $contact-name as xs:string?,
   $contact-title as xs:string?,
   $contact-information 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 create a new Organisation in the metadata repository

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

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

Organization

                {

                  	Organization Name
                    <input type="text" name="org_name"></input>

,

                  	Organization Email Address
                    <input type="text" name="org_mail_address"></input>

              	}

Contact

                {

                  	Name
                    <input type="text" name="contact-name"></input>

,

                  	Title
                    <input type="text" name="contact-title"></input>

,

                  	Information
                    <input type="text" name="contact-information"></input>

              	}

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

          </form>

{$message}

   };

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

Organization created

Return to maintenance menu

Create another Organization

};

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 $title as xs:string := "Creating a New Organisation"
   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 $preferred := request:get-parameter('preferred','')
   let $action := request:get-parameter('update','')
   let $organization_name :=request:get-parameter('org_name','')
   let $organization_mail_address :=request:get-parameter('org_mail_address','')
   let $contact_information :=request:get-parameter('contact-information','')
   let $contact_name :=request:get-parameter('contact-name','')
   let $contact_title :=request:get-parameter('contact-title','')

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store')
      then
         (
         if (
               local:organisation
                  (
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
            )
         then local:success-page()
         else (local:input-page(
            'could not store document',
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $action,
                     $preferred,
                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
               )
         )
      else local:input-page
           (
               '',
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $action,
               $preferred,
               $organization_name,
               $organization_mail_address,
							 $contact_name,
               $contact_title,
               $contact_information
               )
         )


betterFORM-extension:
- fixed typo in xferror.xql

svn path=/stable/eXist-1.4.x/; revision=14304

xquery version "1.0";
import module namespace request="http://exist-db.org/xquery/request";
import module namespace session="http://exist-db.org/xquery/session";

declare option exist:serialize "method=html media-type=text/html";

let $exceptionMessage := session:get-attribute("betterform.exception.message")
let $message1 := substring-before($exceptionMessage,"::")

let $message2 := if ( string-length(substring-after($exceptionMessage,"::")) != 0)
                then substring-after($exceptionMessage,"::")
                else "unknown"

return

	<title>betterFORM Error Page</title>

            Oops, an error occured...

{$message1}

XPath: {$message2}

        <form>
            <input type="button" value="Back" onClick="history.back()"/>
        </form>

xquery version "1.0";
import module namespace request="http://exist-db.org/xquery/request";
import module namespace session="http://exist-db.org/xquery/session";

declare option exist:serialize "method=html media-type=text/html";

let $exceptionMessage := session:get-attribute("betterform.exception")
let $message1 := substring-before($exceptionMessage,"::")

let $message2 := if ( string-length(substring-after($exceptionMessage,"::")) != 0)
                then substring-after($exceptionMessage,"::")
                else "unknown"

return

	<title>betterFORM Error Page</title>

            Oops, an error occured...

{$message1}

XPath: {$message2}

        <form>
            <input type="button" value="Back" onClick="history.back()"/>
        </form>


Add util:eval#4 to exist-db util.xqy

Add util:eval#4 to exist-db util.xqy

This function was introduced with eXist-db 5.3.0
The declaration replaces a duplicate of util:eval#1.

xquery version "3.0";
(:~
 : eXist-db utility module functions
 :
 : @see http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/util&location=java:org.exist.xquery.functions.util.UtilModule&details=true
 :)
module namespace util = "http://exist-db.org/xquery/util";

declare namespace a = "http://reecedunn.co.uk/xquery/annotations";
declare namespace o = "http://reecedunn.co.uk/xquery/options";

declare %a:since("exist", "4.4") function util:absolute-resource-id($node-or-path as item()) as xs:integer? external;
declare %a:since("exist", "4.4") function util:base-to-integer($number as item(), $base as xs:integer) as xs:integer external;
declare %a:since("exist", "4.4") function util:base64-decode($string as xs:string?) as xs:string? external;
declare %a:since("exist", "4.4") function util:base64-encode($string as xs:string?) as xs:string? external;
declare %a:since("exist", "5.3") function util:base64-encode-url-safe($string as xs:string?) as xs:string? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "5.3") function util:base64-encode($string as xs:string?, $trim as xs:boolean) as xs:string? external;
declare %a:since("exist", "4.4") function util:binary-doc($binary-resource as xs:string?) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:binary-doc-available($binary-resource as xs:string?) as xs:boolean external;
declare %a:since("exist", "4.6") function util:binary-doc-content-digest($binary-resource as xs:string?, $algorithm as xs:string) as xs:hexBinary? external;
declare %a:since("exist", "4.4") function util:binary-to-string($binary-resource as xs:base64Binary?) as xs:string? external;
declare %a:since("exist", "4.4") function util:binary-to-string($binary-resource as xs:base64Binary?, $encoding as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:call($function-reference as function(*), $parameters as item()*) as item()* external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") function util:catch($java-classnames as xs:string+, $try-code-blocks as item()*, $catch-code-blocks as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:collations() as xs:string* external;
declare %a:since("exist", "4.4") function util:collection-name($node-or-path-string as item()?) as xs:string? external;
declare %a:since("exist", "4.4") function util:compile($expression as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:compile($expression as xs:string, $module-load-path as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:compile-query($expression as xs:string, $module-load-path as xs:string?) as element() external;
declare %a:since("exist", "4.4") function util:declare-namespace($prefix as xs:string, $namespace-uri as xs:anyURI) as item() external;
declare %a:since("exist", "4.4") function util:declare-option($name as xs:string, $option as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:declared-variables($namespace-uri as xs:string) as xs:string+ external;
declare %a:since("exist", "4.4") function util:deep-copy($item as item()?) as item()? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-function") function util:describe-function($function-name as xs:QName) as node() external;
declare %a:since("exist", "4.4") function util:disable-profiling() as item() external;
declare %a:since("exist", "4.4") function util:doctype($doctype as xs:string+) as node()* external;
declare %a:since("exist", "4.4") function util:document-id($node-or-path as item()) as xs:int? external;
declare %a:since("exist", "4.4") function util:document-name($node-or-path as item()) as xs:string? external;
declare %a:since("exist", "4.4") function util:enable-profiling($verbosity as xs:int) as item() external;
declare %a:since("exist", "4.4") function util:eval($expression as item()) as node()* external;
declare %a:since("exist", "4.4") function util:eval($expression as item(), $cache-flag as xs:boolean) as node()* external;
declare %a:since("exist", "4.4") function util:eval($expression as item(), $cache-flag as xs:boolean, $external-variable as xs:anyType*) as node()* external;
declare %a:since("exist", "5.3") function util:eval($expression as item(), $cache-flag as xs:boolean, $external-variable as xs:anyType*, $pass as xs:boolean) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?, $starting-loc as xs:double) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?, $starting-loc as xs:double, $length as xs:double) as node()* external;
declare %a:since("exist", "4.4") function util:eval-inline($inline-context as item()*, $expression as item()) as item()* external;
declare %a:since("exist", "4.4") function util:eval-inline($inline-context as item()*, $expression as item(), $cache-flag as xs:boolean) as item()* external;
declare %a:since("exist", "4.4") function util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean) as node()* external;
declare %a:since("exist", "4.4") function util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean, $eval-context-item as item()?) as node()* external;
declare %a:since("exist", "4.4") function util:exclusive-lock($nodes as node()*, $expression as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:expand($node as node()*) as node()* external;
declare %a:since("exist", "4.4") function util:expand($node as node()*, $serialization-parameters as xs:string) as node()* external;
declare %a:since("exist", "4.4") function util:function($name as xs:QName, $arity as xs:integer) as function(*) external;
declare %a:since("exist", "4.4") function util:get-fragment-between($beginning-node as node()?, $ending-node as node()?, $make-fragment as xs:boolean?, $display-root-namespace as xs:boolean?) as xs:string external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-module-uri") function util:get-module-description($namespace-uri as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:get-module-info() as element() external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-module-uri") function util:get-module-info($namespace-uri as xs:string) as element() external;
declare %a:since("exist", "4.4") function util:get-option($name as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:get-resource-by-absolute-id($absolute-id as xs:integer) as item()? external;
declare %a:since("exist", "4.4") function util:get-sequence-type($sequence-type as xs:anyType*) as xs:string external;
declare %a:since("exist", "4.4") function util:hash($message as item(), $algorithm as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:hash($message as item(), $algorithm as xs:string, $base64flag as xs:boolean) as xs:string external;
declare %a:since("exist", "4.4") function util:import-module($module-uri as xs:anyURI, $prefix as xs:string, $location as xs:anyURI) as item() external;
declare %a:since("exist", "4.4") function util:index-key-documents($nodes as node()*, $value as xs:anyAtomicType) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-documents($nodes as node()*, $value as xs:anyAtomicType, $index as xs:string) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-occurrences($nodes as node()*, $value as xs:anyAtomicType) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-occurrences($nodes as node()*, $value as xs:anyAtomicType, $index as xs:string) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-keys($node-set as node()*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?) as item()* external;
declare %a:since("exist", "4.4") function util:index-keys($node-set as node()*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?, $index as xs:string) as item()* external;
declare %a:since("exist", "4.4") function util:index-keys-by-qname($qname as xs:QName*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?, $index as xs:string) as item()* external;
declare %a:since("exist", "4.4") function util:index-type($set-of-nodes as node()*) as xs:string? external;
declare %a:since("exist", "4.4") function util:inspect-function($function as function(*)) as node() external;
declare %a:since("exist", "4.4") function util:int-to-octal($int as xs:int) as xs:string external;
declare %a:since("exist", "4.4") function util:integer-to-base($number as xs:integer, $base as xs:integer) as xs:string external;
declare %a:since("exist", "4.4") function util:is-binary-doc($binary-resource as xs:string?) as xs:boolean external;
declare %a:since("exist", "4.4") function util:is-module-mapped($namespace-uri as xs:string) as xs:boolean external;
declare %a:since("exist", "4.4") function util:is-module-registered($namespace-uri as xs:string) as xs:boolean external;
declare %a:since("exist", "4.4") function util:line-number() as xs:integer external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:module-functions") function util:list-functions() as function(*)* external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:module-functions") function util:list-functions($namespace-uri as xs:string) as function(*)* external;
declare %a:since("exist", "4.4") function util:log($priority as xs:string, $message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-app($priority as xs:string, $logger-name as xs:string, $message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-system-err($message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-system-out($message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:map-module($namespace-uri as xs:string, $location-uri as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:mapped-modules() as xs:string+ external;
declare %a:since("exist", "4.4") function util:node-by-id($document as node(), $node-id as xs:string) as node() external;
declare %a:since("exist", "4.4") function util:node-id($node as node()) as xs:string external;
declare %a:since("exist", "4.4") function util:node-xpath($node as node()) as xs:string? external;
declare %a:since("exist", "4.4") function util:octal-to-int($octal as xs:string) as xs:int external;
declare %a:since("exist", "4.4") function util:parse($to-be-parsed as xs:string?) as document-node()? external;
declare %a:since("exist", "4.4") function util:parse-html($to-be-parsed as xs:string?) as document-node()? external;
declare %a:since("exist", "4.4") function util:qname-index-lookup($qname as xs:QName, $comparison-value as xs:anyAtomicType) as node()* external;
(:~
 : Returns a random number between 0e0 and 1e0.
 :
 : This function returns a random number such that
 : 0e0 <= math-ext:random() < 1e0.
 :)
declare %a:since("exist", "4.4") function util:random() as xs:double external;
declare %a:since("exist", "4.4") function util:random($max as xs:integer) as xs:integer external;
declare %a:since("exist", "4.4") function util:random-ulong() as xs:unsignedLong external;
declare %a:since("exist", "4.4") function util:registered-functions() as xs:string+ external;
declare %a:since("exist", "4.4") function util:registered-functions($namespace-uri as xs:string) as xs:string+ external;
declare %a:since("exist", "4.4") function util:registered-modules() as xs:string+ external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("xpath-functions", "3.0-20140408", "fn:serialize") function util:serialize($node-set as node()*, $parameters as item()*) as xs:string? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("xpath-functions", "3.0-20140408", "fn:serialize") function util:serialize($a as node()*, $b as xs:string, $c as xs:string*) as xs:boolean? external;
declare %a:since("exist", "4.4") function util:shared-lock($nodes as node()*, $expression as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:string-to-binary($encoded-string as xs:string?) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:string-to-binary($encoded-string as xs:string?, $encoding as xs:string) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:system-date() as xs:date external;
declare %a:since("exist", "4.4") function util:system-dateTime() as xs:dateTime external;
declare %a:since("exist", "4.4") function util:system-property($property-name as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:system-time() as xs:time external;
declare %a:since("exist", "4.4") function util:unescape-uri($escaped-string as xs:string, $encoding as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:unmap-module($namespace-uri as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:uuid() as xs:string external;
declare %a:since("exist", "4.4") function util:uuid($name as item()) as xs:string external;
declare %a:since("exist", "4.4") function util:wait($interval as xs:integer) as item() external;

xquery version "3.0";
(:~
 : eXist-db utility module functions
 :
 : @see http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/util&location=java:org.exist.xquery.functions.util.UtilModule&details=true
 :)
module namespace util = "http://exist-db.org/xquery/util";

declare namespace a = "http://reecedunn.co.uk/xquery/annotations";
declare namespace o = "http://reecedunn.co.uk/xquery/options";

declare %a:since("exist", "4.4") function util:absolute-resource-id($node-or-path as item()) as xs:integer? external;
declare %a:since("exist", "4.4") function util:base-to-integer($number as item(), $base as xs:integer) as xs:integer external;
declare %a:since("exist", "4.4") function util:base64-decode($string as xs:string?) as xs:string? external;
declare %a:since("exist", "4.4") function util:base64-encode($string as xs:string?) as xs:string? external;
declare %a:since("exist", "5.3") function util:base64-encode-url-safe($string as xs:string?) as xs:string? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "5.3") function util:base64-encode($string as xs:string?, $trim as xs:boolean) as xs:string? external;
declare %a:since("exist", "4.4") function util:binary-doc($binary-resource as xs:string?) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:binary-doc-available($binary-resource as xs:string?) as xs:boolean external;
declare %a:since("exist", "4.6") function util:binary-doc-content-digest($binary-resource as xs:string?, $algorithm as xs:string) as xs:hexBinary? external;
declare %a:since("exist", "4.4") function util:binary-to-string($binary-resource as xs:base64Binary?) as xs:string? external;
declare %a:since("exist", "4.4") function util:binary-to-string($binary-resource as xs:base64Binary?, $encoding as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:call($function-reference as function(*), $parameters as item()*) as item()* external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") function util:catch($java-classnames as xs:string+, $try-code-blocks as item()*, $catch-code-blocks as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:collations() as xs:string* external;
declare %a:since("exist", "4.4") function util:collection-name($node-or-path-string as item()?) as xs:string? external;
declare %a:since("exist", "4.4") function util:compile($expression as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:compile($expression as xs:string, $module-load-path as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:compile-query($expression as xs:string, $module-load-path as xs:string?) as element() external;
declare %a:since("exist", "4.4") function util:declare-namespace($prefix as xs:string, $namespace-uri as xs:anyURI) as item() external;
declare %a:since("exist", "4.4") function util:declare-option($name as xs:string, $option as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:declared-variables($namespace-uri as xs:string) as xs:string+ external;
declare %a:since("exist", "4.4") function util:deep-copy($item as item()?) as item()? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-function") function util:describe-function($function-name as xs:QName) as node() external;
declare %a:since("exist", "4.4") function util:disable-profiling() as item() external;
declare %a:since("exist", "4.4") function util:doctype($doctype as xs:string+) as node()* external;
declare %a:since("exist", "4.4") function util:document-id($node-or-path as item()) as xs:int? external;
declare %a:since("exist", "4.4") function util:document-name($node-or-path as item()) as xs:string? external;
declare %a:since("exist", "4.4") function util:enable-profiling($verbosity as xs:int) as item() external;
declare %a:since("exist", "4.4") function util:eval($expression as item()) as node()* external;
declare %a:since("exist", "4.4") function util:eval($expression as item(), $cache-flag as xs:boolean) as node()* external;
declare %a:since("exist", "4.4") function util:eval($expression as item(), $cache-flag as xs:boolean, $external-variable as xs:anyType*) as node()* external;
declare %a:since("exist", "4.4") function util:eval($expression as item()) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?, $starting-loc as xs:double) as node()* external;
declare %a:since("exist", "4.6") function util:eval-and-serialize($expression as item(), $default-serialization-params as item()?, $starting-loc as xs:double, $length as xs:double) as node()* external;
declare %a:since("exist", "4.4") function util:eval-inline($inline-context as item()*, $expression as item()) as item()* external;
declare %a:since("exist", "4.4") function util:eval-inline($inline-context as item()*, $expression as item(), $cache-flag as xs:boolean) as item()* external;
declare %a:since("exist", "4.4") function util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean) as node()* external;
declare %a:since("exist", "4.4") function util:eval-with-context($expression as item(), $context as node()?, $cache-flag as xs:boolean, $eval-context-item as item()?) as node()* external;
declare %a:since("exist", "4.4") function util:exclusive-lock($nodes as node()*, $expression as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:expand($node as node()*) as node()* external;
declare %a:since("exist", "4.4") function util:expand($node as node()*, $serialization-parameters as xs:string) as node()* external;
declare %a:since("exist", "4.4") function util:function($name as xs:QName, $arity as xs:integer) as function(*) external;
declare %a:since("exist", "4.4") function util:get-fragment-between($beginning-node as node()?, $ending-node as node()?, $make-fragment as xs:boolean?, $display-root-namespace as xs:boolean?) as xs:string external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-module-uri") function util:get-module-description($namespace-uri as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:get-module-info() as element() external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:inspect-module-uri") function util:get-module-info($namespace-uri as xs:string) as element() external;
declare %a:since("exist", "4.4") function util:get-option($name as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:get-resource-by-absolute-id($absolute-id as xs:integer) as item()? external;
declare %a:since("exist", "4.4") function util:get-sequence-type($sequence-type as xs:anyType*) as xs:string external;
declare %a:since("exist", "4.4") function util:hash($message as item(), $algorithm as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:hash($message as item(), $algorithm as xs:string, $base64flag as xs:boolean) as xs:string external;
declare %a:since("exist", "4.4") function util:import-module($module-uri as xs:anyURI, $prefix as xs:string, $location as xs:anyURI) as item() external;
declare %a:since("exist", "4.4") function util:index-key-documents($nodes as node()*, $value as xs:anyAtomicType) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-documents($nodes as node()*, $value as xs:anyAtomicType, $index as xs:string) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-occurrences($nodes as node()*, $value as xs:anyAtomicType) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-key-occurrences($nodes as node()*, $value as xs:anyAtomicType, $index as xs:string) as xs:integer? external;
declare %a:since("exist", "4.4") function util:index-keys($node-set as node()*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?) as item()* external;
declare %a:since("exist", "4.4") function util:index-keys($node-set as node()*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?, $index as xs:string) as item()* external;
declare %a:since("exist", "4.4") function util:index-keys-by-qname($qname as xs:QName*, $start-value as xs:anyAtomicType?, $function-reference as function(*), $max-number-returned as xs:int?, $index as xs:string) as item()* external;
declare %a:since("exist", "4.4") function util:index-type($set-of-nodes as node()*) as xs:string? external;
declare %a:since("exist", "4.4") function util:inspect-function($function as function(*)) as node() external;
declare %a:since("exist", "4.4") function util:int-to-octal($int as xs:int) as xs:string external;
declare %a:since("exist", "4.4") function util:integer-to-base($number as xs:integer, $base as xs:integer) as xs:string external;
declare %a:since("exist", "4.4") function util:is-binary-doc($binary-resource as xs:string?) as xs:boolean external;
declare %a:since("exist", "4.4") function util:is-module-mapped($namespace-uri as xs:string) as xs:boolean external;
declare %a:since("exist", "4.4") function util:is-module-registered($namespace-uri as xs:string) as xs:boolean external;
declare %a:since("exist", "4.4") function util:line-number() as xs:integer external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:module-functions") function util:list-functions() as function(*)* external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("exist", "4.4", "inspect:module-functions") function util:list-functions($namespace-uri as xs:string) as function(*)* external;
declare %a:since("exist", "4.4") function util:log($priority as xs:string, $message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-app($priority as xs:string, $logger-name as xs:string, $message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-system-err($message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:log-system-out($message as item()*) as item() external;
declare %a:since("exist", "4.4") function util:map-module($namespace-uri as xs:string, $location-uri as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:mapped-modules() as xs:string+ external;
declare %a:since("exist", "4.4") function util:node-by-id($document as node(), $node-id as xs:string) as node() external;
declare %a:since("exist", "4.4") function util:node-id($node as node()) as xs:string external;
declare %a:since("exist", "4.4") function util:node-xpath($node as node()) as xs:string? external;
declare %a:since("exist", "4.4") function util:octal-to-int($octal as xs:string) as xs:int external;
declare %a:since("exist", "4.4") function util:parse($to-be-parsed as xs:string?) as document-node()? external;
declare %a:since("exist", "4.4") function util:parse-html($to-be-parsed as xs:string?) as document-node()? external;
declare %a:since("exist", "4.4") function util:qname-index-lookup($qname as xs:QName, $comparison-value as xs:anyAtomicType) as node()* external;
(:~
 : Returns a random number between 0e0 and 1e0.
 :
 : This function returns a random number such that
 : 0e0 <= math-ext:random() < 1e0.
 :)
declare %a:since("exist", "4.4") function util:random() as xs:double external;
declare %a:since("exist", "4.4") function util:random($max as xs:integer) as xs:integer external;
declare %a:since("exist", "4.4") function util:random-ulong() as xs:unsignedLong external;
declare %a:since("exist", "4.4") function util:registered-functions() as xs:string+ external;
declare %a:since("exist", "4.4") function util:registered-functions($namespace-uri as xs:string) as xs:string+ external;
declare %a:since("exist", "4.4") function util:registered-modules() as xs:string+ external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("xpath-functions", "3.0-20140408", "fn:serialize") function util:serialize($node-set as node()*, $parameters as item()*) as xs:string? external;
declare %a:since("exist", "4.4") %a:deprecated("exist", "4.4") %a:see-also("xpath-functions", "3.0-20140408", "fn:serialize") function util:serialize($a as node()*, $b as xs:string, $c as xs:string*) as xs:boolean? external;
declare %a:since("exist", "4.4") function util:shared-lock($nodes as node()*, $expression as item()*) as item()* external;
declare %a:since("exist", "4.4") function util:string-to-binary($encoded-string as xs:string?) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:string-to-binary($encoded-string as xs:string?, $encoding as xs:string) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function util:system-date() as xs:date external;
declare %a:since("exist", "4.4") function util:system-dateTime() as xs:dateTime external;
declare %a:since("exist", "4.4") function util:system-property($property-name as xs:string) as xs:string? external;
declare %a:since("exist", "4.4") function util:system-time() as xs:time external;
declare %a:since("exist", "4.4") function util:unescape-uri($escaped-string as xs:string, $encoding as xs:string) as xs:string external;
declare %a:since("exist", "4.4") function util:unmap-module($namespace-uri as xs:string) as item() external;
declare %a:since("exist", "4.4") function util:uuid() as xs:string external;
declare %a:since("exist", "4.4") function util:uuid($name as item()) as xs:string external;
declare %a:since("exist", "4.4") function util:wait($interval as xs:integer) as item() external;


Added table id for CSS

Added table id for CSS

module namespace template="http://cefn.com/readinglog/template";

import module namespace notes="http://cefn.com/readinglog/notes" at "/home/cefn/Documents/highwire/participatory firmware design/readinglog/scripts/server/xquery/lib/notes.xq";
import module namespace file = "http://expath.org/ns/file";

declare default element namespace "http://www.w3.org/1999/xhtml";

declare namespace ann = "http://www.zorba-xquery.com/annotations";

(: templates a webpage, including the nodes specified :)
declare function template:webpage($nodes){

		    <meta content="text/html; charset=utf-16" http-equiv="content-type"></meta>
			<link href="style.css" rel="stylesheet" type="text/css"></link>

								{template:menu()}

								{$nodes}

};

(: Returns all the document nodes of well-formed XHTML files in a given directory :)
declare %ann:nondeterministic function template:loadhtml($dirpath) {
	for $file in file:list($dirpath) where matches($file,'.+\.html$')
	let $absfile := file:resolve-path(concat($dirpath,$file))
	return doc($absfile)
};

(: Returns all the document nodes of the XHTML note files :)
declare function template:menu(){

		{
			for $item in $notes:headings return

{$item}

		}

};


Fixed a bug when checking for multiple credentials

import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl";
import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu";
declare default element  namespace   "urn:ihe:iti:csd:2013";
declare variable $careServicesRequest as item() external;

(:
   The query will be executed against the root element of the CSD document.

   The dynamic context of this query has $careServicesRequest set to contain any of the search
   and limit paramaters as sent by the Service Finder
:)

let $provs0 := if (exists($careServicesRequest/id/@entityID)) then	csd_bl:filter_by_primary_id(/CSD/providerDirectory/*,$careServicesRequest/id) else ()
let $provs1 := if (count($provs0) = 1) then $provs0 else ()
let $provs2 := if (exists($careServicesRequest/credential/codedType/@code) and exists($careServicesRequest/credential/codedType/@codingScheme) ) then $provs1  else ()
let $cred_request := $careServicesRequest/credential
let $code:= $cred_request/codedType/@code
let $codingScheme:= $cred_request/codedType/@codingScheme
let $creds0 := $provs2/credential/codedType[@code = $code and @codingScheme = $codingScheme]
return
  if ( count($provs2) = 1 and count($creds0) = 0)  (:DO NOT ALLOW SAME CRED TWICE :)
    then
    let $provider:= $provs2[1]
    let $cred_rec :=
    <credential>
      <codedType code="{$code}" codingScheme="{$codingScheme}"/>
    </credential>
    let $cred_new :=
    <credential>
      <codedType code="{$code}" codingScheme="{$codingScheme}"/>
      {(
	if (exists($cred_request/number)) then $cred_request/number else (),
	if (exists($cred_request/issuingAuthority)) then $cred_request/issuingAuthority else (),
	if (exists($cred_request/credentialIssueDate)) then $cred_request/credentialIssueDate else (),
        if (exists($cred_request/credentialRenewalDate)) then $cred_request/credentialRenewalDate else ()
      )}
    </credential>
    let $provs3:=
    <provider entityID="{$provider/@entityID}">{$cred_rec}</provider>
    return
	(
	insert node $cred_new into $provider,
	csd_blu:wrap_updating_providers($provs3)
	)

  else  csd_blu:wrap_updating_providers(())

import module namespace csd_bl = "https://github.com/openhie/openinfoman/csd_bl";
import module namespace csd_blu = "https://github.com/openhie/openinfoman/csd_blu";
declare default element  namespace   "urn:ihe:iti:csd:2013";
declare variable $careServicesRequest as item() external;

(:
   The query will be executed against the root element of the CSD document.

   The dynamic context of this query has $careServicesRequest set to contain any of the search
   and limit paramaters as sent by the Service Finder
:)

let $provs0 := if (exists($careServicesRequest/id/@entityID)) then	csd_bl:filter_by_primary_id(/CSD/providerDirectory/*,$careServicesRequest/id) else ()
let $provs1 := if (count($provs0) = 1) then $provs0 else ()
let $provs2 := if (exists($careServicesRequest/credential/codedType/@code) and exists($careServicesRequest/credential/codedType/@codingScheme) ) then $provs1  else ()
let $cred_request := $careServicesRequest/credential
let $code:= $cred_request/codedType/@code
let $codingScheme:= $cred_request/codedType/@codingScheme
let $creds0 := $provs2/credential[@code = $code and @codingScheme = $codingScheme]
return
  if ( count($provs2) = 1 and count($creds0) = 0)  (:DO NOT ALLOW SAME CRED TWICE :)
    then
    let $provider:= $provs2[1]
    let $cred_rec :=
    <credential>
      <codedType code="{$code}" codingScheme="{$codingScheme}"/>
    </credential>
    let $cred_new :=
    <credential>
      <codedType code="{$code}" codingScheme="{$codingScheme}"/>
      {(
	if (exists($cred_request/number)) then $cred_request/number else (),
	if (exists($cred_request/issuingAuthority)) then $cred_request/issuingAuthority else (),
	if (exists($cred_request/credentialIssueDate)) then $cred_request/credentialIssueDate else (),
        if (exists($cred_request/credentialRenewalDate)) then $cred_request/credentialRenewalDate else ()
      )}
    </credential>
    let $provs3:=
    <provider entityID="{$provider/@entityID}">{$cred_rec}</provider>
    return
	(
	insert node $cred_new into $provider,
	csd_blu:wrap_updating_providers($provs3)
	)

  else  csd_blu:wrap_updating_providers(())