Added units tests.

Added units tests.

(:
 : @author James Wright
 : Tests for xq-promise library
 :)
module namespace test = 'http://basex.org/modules/xqunit-tests';
import module namespace promise = 'org.jw.basex.async.xq-promise';

declare %unit:test function test:promise() {
   let $work := function ($name) {
     'Hello ' || $name || '!'
   }
   let $promise := promise:defer($work, 'world')
   return
      unit:assert-equals($promise(()), 'Hello world!')
 };

declare %unit:test function test:callbacks-add() {
  for $type in ('then', 'done', 'always')
  return
    let $path := file:temp-dir() || $type || '.txt'
    let $callback := file:write-text($path, ?)
    let $work := promise:defer(trace(?, 'Hello world!'))
    let $promise := $work(map { $type: $callback })
    return
      ($promise(()), file:exists($path), file:delete($path))
};

declare %unit:test function test:callbacks-fail() {
  let $path := file:temp-dir() 'fail.txt'
  let $callback := file:write-text($path, ?)
  let $work := promise:defer(function () { fn:error('Failed!') })
  let $promise := $work(map { 'fail': $callback })
  return
    ($promise(()), file:exists($path), file:delete($path))
};

declare %unit:test function test:callbacks-fail-fix-value() {
  let $callback := function () { 'Hello world!' }
  let $work := promise:defer(function () { fn:error('Failed!') })
  let $promise := $work(map { 'fail': $callback })
  return
    unit:assert-equals($promise(()), 'Hello world!')
};

declare %unit:test function test:callbacks-fail-fatal() {
  let $callback := function () { fn:error('Callback Failed!') }
  let $work := promise:defer(function () { fn:error('Failed!') })
  let $promise := $work(map { 'fail': $callback })
  let $result :=
    try {
      unit:assert-equals($promise(()), 'Hello world!')
    } catch * { ('Failed!') }
  return
   unit:assert-equals($result, 'Failed!')
}

declare %unit:test function test:callback-then() {
  let $greet := function ($res) { 'Hello ' || $name || '!'}
  let $promise :=
      promise:defer(trace(?), 'world', map {
          'then': $greet
      })
  return
    unit:assert-equals($promise(()), 'Hello world!')
};

declare %unit:test function test:multiple-callbacks() {
  let $greet := function ($res) { 'Hello ' || $name }
  let $get-end := function ($name) { $name || '!' }
  let $promise :=
      promise:defer(trace(?), 'world', map {
          'then': ($get-end, $greet)
      })
  return
    unit:assert-equals($promise(()), 'Hello world!')
}

declare %unit:test function test:callbacks-attached-after() {
  let $greet := function ($res) { 'Hello ' || $name }
  let $get-end := function ($name) { $name || '!' }
  let $work := promise:defer(trace(?), 'world')
  let $get := $work(map { 'then': $get-end })
  let $promise := $get(map { 'then': $greet })
  return
    unit:assert-equals($promise(()), 'Hello world!')
}

declare %unit:test function test:when-with-same-arity() {
  let $greet := function ($greeting, $name) { $greeting || ' ' || $name || '!'}
  let $promise :=
    promise:when((
      promise:defer(trace(?), 'Hello'),
      promise:defer(trace(?), 'world'),
      map { 'then': $greet }
  ))
  return
   unit:assert-equals($promise(()), 'Hello world!')
}

declare %unit:test function test:when-with-diff-arity() {
  let $greet := function ($args) { $args?1 || ' ' || $args?2 || '!'}
  let $promise :=
    promise:when((
      promise:defer(trace(?), 'Hello'),
      promise:defer(trace(?), 'world'),
      map { 'then': $greet }
  ))
  return
   unit:assert-equals($promise(()), 'Hello world!')
}

declare %unit:test function test:fork-join() {
  let $work := function ($input) { element {text} {$input} }
  let $promises :=
    for $i in (1 to 1000) return
      promise:defer($work, $i)
  return
    let $out := promise:fork-join($promises, map {
    let $sum := sum($out)
    return
      unit:assert-equals($sum, 500500)
}

declare %unit:test function test:fork-join-shared-resource() {
  let $shared := map ( for $i in 1000 return map { 'value':$i })
  let $work := function ($input) {
    let $value := $shared?*[. = $input]
    return
      element {text} {json:serialize($input)}
  }
  let $promises := for $i in (1 to 1000)
                   return promise:defer($work, $i)
  return
    let $out := promise:fork-join($promises)
    let $sum := sum(($nodes ! json:parse(.))?value)
    return
      unit:assert-equals($sum, 500500)
}

error: pathspec 'tests/xq-promise-test.xq' did not match any file(s) known to git


Introduced cleanup preprocessing of definitions

xquery version "1.0-ml";

declare variable $xml external;
let $xml := xdmp:unquote("<wrap>" || $xml || "</wrap>")

let $definition := xdmp:xslt-eval(
  <xsl:stylesheet version="2.0" exclude-result-prefixes="#all" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:apidoc="http://marklogic.com/xdmp/apidoc" xmlns:local="local">

    <xsl:strip-space elements="*"/>
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

    <!-- copy all by default -->

    <xsl:template match="@*|node()" mode="#all">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()" mode="#current"/>
      </xsl:copy>
    </xsl:template>

    <!-- root template -->

    <xsl:template match="/wrap">
      <!-- jump to other mode -->
      <xsl:apply-templates select="." mode="sort"/>
    </xsl:template>

    <!-- strip-non-javascript -->

    <xsl:template match="apidoc:module[not(@class = 'xquery')]" mode="strip-non-javascript">
      <!-- jump to other mode -->
      <xsl:apply-templates select="." mode="sort"/>
    </xsl:template>

      <!-- module, summary, function, param, return -->
    <xsl:template match="*[@class = 'xquery']|*[@http-verb]|apidoc:function[@name = '']|apidoc:function[apidoc:summary[contains(lower-case(.), 'deprecated')]]" mode="strip-non-javascript"/>

    <xsl:template match="apidoc:function[not(@class = 'xquery')][empty(@http-verb)][not(@name = '')][empty(apidoc:summary[contains(lower-case(.), 'deprecated')])]" mode="strip-non-javascript">
      <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates select="node()" mode="strip-non-javascript"/>
      </xsl:copy>
    </xsl:template>

    <xsl:template match="apidoc:param[not(@class = 'xquery')]" mode="strip-non-javascript">
      <!-- jump to other mode -->
      <xsl:apply-templates select="." mode="cleanup-types"/>
    </xsl:template>

    <xsl:template match="apidoc:return[not(@class = 'xquery')]" mode="strip-non-javascript">
      <!-- jump to other mode -->
      <xsl:apply-templates select="." mode="cleanup-types"/>
    </xsl:template>

    <!-- sort -->

    <xsl:template match="/wrap" mode="sort">
      <!-- jump to other mode -->
      <xsl:apply-templates select="apidoc:module" mode="strip-non-javascript">
        <xsl:sort select="(@lib, 'xdmp')[1]"/>
      </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="apidoc:module" mode="sort">
      <xsl:copy>
        <xsl:copy-of select="@*"/>
        <!-- jump to other mode -->
        <xsl:apply-templates select="apidoc:summary" mode="strip-non-javascript"/>
        <xsl:apply-templates select="apidoc:function" mode="strip-non-javascript">
          <xsl:sort select="@name"/>
        </xsl:apply-templates>
      </xsl:copy>
    </xsl:template>

    <!-- cleanup-types -->

    <xsl:template match="apidoc:param" mode="cleanup-types">
      <xsl:variable name="type" select="normalize-space(@type)"/>
      <xsl:copy>
        <xsl:copy-of select="@* except (@optional, @type)" />
        <xsl:choose>
          <xsl:when test="matches($type, '^\[.*\]$')">
            <xsl:attribute name="type" select="substring($type, 2, string-length($type) - 2)"/>
            <xsl:attribute name="optional" select="'true'"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:copy-of select="@type" />
          </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="empty(following-sibling::apidoc:param[@optional = false() or empty(@optional)])">
          <xsl:copy-of select="@optional" />
        </xsl:if>
        <xsl:copy-of select="node()" />
      </xsl:copy>
    </xsl:template>

    <xsl:template match="apidoc:param/@type" mode="cleanup-types">
      <xsl:variable name="type" select="normalize-space()"/>
      <xsl:copy>
        <xsl:choose>
          <xsl:when test="matches($type, '^\[.*\]$')">
            <xsl:attribute name="optional" select="'true'"/>
            <xsl:value-of select="substring($type, 2, string-length($type) - 2)"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="'XXX'"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:copy>
    </xsl:template>

    <xsl:template match="apidoc:return" mode="cleanup-types">
      <xsl:variable name="return" select="normalize-space()"/>
      <xsl:copy>
        <xsl:copy-of select="@*" />
        <xsl:choose>
          <xsl:when test="$return = ('empty-sequence()')">null</xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$return"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:copy>
    </xsl:template>

  </xsl:stylesheet>, $xml)

return xdmp:quote($definition, map:new((map:entry("indent", "yes"), map:entry("indentUntyped", "yes"))))

error: pathspec 'qconsole/cleanup-definitions.xqy' did not match any file(s) known to git


add tests for question marks in contains function #1379

xquery version "3.1";

(:~
 : these tests were created because of
 : https://github.com/eXist-db/exist/issues/1379
~:)

module namespace ct="http://exist-db.org/xquery/test/question-marks-in-contains-function";

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $ct:test :=
    <root>
        <persName xmlns="http://www.tei-c.org/ns/1.0">
            <surname>Hering</surname>, <forename>S(amuel?)</forename>
        </persName>
        <persName xmlns="http://www.tei-c.org/ns/1.0">
            <surname>Hering</surname>, <forename>Samuel</forename>
        </persName>
    </root>;

declare variable $ct:xconf :=
    <collection xmlns="http://exist-db.org/collection-config/1.0">
        <index xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <range>
                <create qname="tei:surname" type="xs:string"/>
                <create qname="tei:forename" type="xs:string"/>
                <create qname="tei:persName" type="xs:string"/>
            </range>
        </index>
    </collection>;

declare %test:setUp function ct:setup() {
    xmldb:create-collection("/db/system/config/db", "test"),
    xmldb:store("/db/system/config/db/test", "collection.xconf", $ct:xconf),
    xmldb:create-collection("/db", "test"),
    xmldb:store("/db/test", "test.xml", $ct:test)
};

declare %test:tearDown function ct:teardown() {
    xmldb:remove("/db/test"),
    xmldb:remove("/db/system/config/db/test")
};

declare %test:assertEquals(1) %test:pending function ct:element-contains-question-mark() {
    let $hits := doc("/db/test/test.xml")//tei:forename[fn:contains(., "?")]
    return
        count($hits)
};

declare %test:assertEquals(0) %test:pending function ct:element-contains-escaped-question-mark() {
    let $hits := doc("/db/test/test.xml")//tei:forename[fn:contains(., "\?")]
    return
        count($hits)
};

declare %test:assertEquals(1) %test:pending function ct:parent-element-contains-question-mark() {
    let $hits := doc("/db/test/test.xml")//tei:persName[fn:contains(., "?")]
    return
        count($hits)
};

declare %test:assertEquals(0) function ct:parent-element-contains-escaped-question-mark() {
    let $hits := doc("/db/test/test.xml")//tei:persName[fn:contains(., "\?")]
    return
        count($hits)
};

error: pathspec 'test/src/xquery/question-marks-in-contains-function.xql' did not match any file(s) known to git


[testsuite] Add tests from issue #2437 which are also fixed now

xquery version "3.1";

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

declare variable $devar:static := 'I am static.';
declare variable $devar:dynamic := replace($devar:static, 'static', 'dynamic');
declare variable $devar:function := (function ($a) {
    replace($a, 'static', 'the return of a function expression')
})($devar:static);

declare variable $devar:arrow := $devar:static
=> replace('static', 'the return of an arrow expression')
;

declare
%test:assertEquals('I am static.')
function devar:read-static () {
    $devar:static
};

declare
%test:assertEquals('I am dynamic.')
function devar:read-dynamic () {
    $devar:dynamic
};

declare
%test:assertEquals('I am the return of a function expression.')
function devar:read-function () {
    $devar:function
};

declare
%test:assertEquals('I am the return of a arrow expression.')
function devar:read-arrow () {
    $devar:arrow
};

error: pathspec 'exist-core/src/test/xquery/xquery3/dynamically-declared-vars.xql' did not match any file(s) known to git


forgot to add a test

forgot to add a test

variable $doc := <doc></doc>;

($doc/a)[if (position() > 3) then position() else 1]

error: pathspec 'test/rbkt/Queries/zorba/optim/pos_pred11.xq' did not match any file(s) known to git


Earliest notice submission date XQuery

Earliest notice submission date XQuery

declare option saxon:output "omit-xml-declaration=yes";
declare option saxon:output "method=text";

min(/PrehledZakazekZVestnikuVZ/VerejnaZakazka/DatumOdeslaniFormulareNaVVZ)

error: pathspec 'xquery/earliest_notice_submission_date.xq' did not match any file(s) known to git


test: add testsuite for literals in curly braces

xquery version "3.1";

(:~
    These tests emerged from research regarding
    https://github.com/eXist-db/exist/issues/291

    The xquery-parser MUST recognize a curly brace expression,
    if it starts with a literal string.
~:)
module namespace litcurl="http://exist-db.org/xquery/test/literals-in-curlies";
declare namespace test="http://exist-db.org/xquery/xqsuite";

declare
    %test:pending
    %test:assertEquals("<root a='a'/>")
function litcurl:literalString() {
(:
 : Since the line below raises a static error, it cannot be tested yet.
 : When the xquery parser is fixed, uncomment it and remove the zero.
 : <root a="{'a'}"/>
 :)
    0
};

(:~ other literals ~:)
declare
    %test:assertEquals("<root a='true'/>")
function litcurl:literalBooleanTrue() {
    <root a="{true()}"/>
};

declare
    %test:assertEquals("<root a='false'/>")
function litcurl:literalBooleanFalse() {
    <root a="{false()}"/>
};

declare
    %test:assertEquals("<root a='0'/>")
function litcurl:literalNumberZero() {
    <root a="{0}"/>
};

declare
    %test:assertEquals("<root a='1'/>")
function litcurl:literalNumberOne() {
    <root a="{1}"/>
};
declare
    %test:assertEquals("<root a='-1'/>")
function litcurl:literalNumberNegativeOne() {
    <root a="{-1}"/>
};

declare
    %test:assertEquals("<root a='1.1111'/>")
function litcurl:literalDecimal() {
    <root a="{1.1111}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:typeConversionToString() {
    <root a="{xs:string('a')}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:concatStringWithEmptySequence() {
    <root a="{() || 'a'}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:sequenceWithOneLiteralString() {
    <root a="{('a')}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:firstArrayElement() {
    <root a="{['a']?1}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:variableSubstitution() {
    let $a := 'a'
    return <root a="{$a}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:stringConstructor() {
    <root a="{``[a]``}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:mapProperty() {
    <root a="{map{'a':'a'}?a}"/>
};

error: pathspec 'test/src/xquery/literals-in-curlies.xql' did not match any file(s) known to git


Display linguistic information.

Display linguistic information.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/julen/tzos.git/'


Added xq file expressing query 3 using XQuery

Web data management & xml (CSE 5335)/Programming assignment 7/Individual queries/3.xq

/bin/sh: 1: Syntax error: word unexpected (expecting ")")


[test] Tests for util:document-id

[test] Tests for util:document-id

(:
 : 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 docid = "http://exist-db.org/test/util/document-id";

import module namespace util = "http://exist-db.org/xquery/util";

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

declare
    %test:setUp
function docid:setup() {
    xmldb:store("/db", "docid.xml", <doc>/db</doc>),
    xmldb:create-collection("/db", "test-docid"),
    xmldb:store("/db/test-docid", "docid.xml", <doc>/db/test-docid</doc>)
};

declare
    %test:tearDown
function docid:teardown() {
    xmldb:remove("/db/test-docid"),
    xmldb:remove("/db", "docid.xml")
};

declare
    %test:assertEquals('<doc>/db</doc>')
function docid:by-resource-id-root() {
    let $doc := doc("/db/docid.xml")
    let $id := util:absolute-resource-id($doc)
    return
    	util:get-resource-by-absolute-id($id)
};

declare
    %test:assertEquals('<doc>/db/test-docid</doc>')
function docid:by-resource-id() {
    let $doc := doc("/db/test-docid/docid.xml")
    let $id := util:absolute-resource-id($doc)
    return
    	util:get-resource-by-absolute-id($id)
};

declare
    %test:args("1")
    %test:assertEquals('<doc>/db</doc>')
    %test:args("1.1")
    %test:assertEquals('/db')
    %test:args("1.15")
    %test:assertEmpty
function docid:node-by-id($id as xs:string) {
    util:node-by-id(doc("/db/docid.xml"), $id)
};

declare
    %test:args("/db/docid.xml")
    %test:assertEquals("docid.xml")
    %test:args("/db/test-docid/docid.xml")
    %test:assertEquals("docid.xml")
function docid:document-name-from-node($doc-path as xs:string) {
  let $doc := doc($doc-path)
  return
    util:document-name($doc)
};

declare
    %test:args("/db/docid.xml")
    %test:assertEquals("docid.xml")
    %test:args("/db/test-docid/docid.xml")
    %test:assertEquals("docid.xml")
    %test:args("/db/no-such-document.xml")
    %test:assertEmpty
function docid:document-name-from-path($doc-path as xs:string) {
  util:document-name($doc-path)
};

declare
    %test:args("/db/docid.xml")
    %test:assertEquals(7)
    %test:args("/db/test-docid/docid.xml")
    %test:assertEquals(8)
function docid:document-id-from-node($doc-path as xs:string) {
  let $doc := doc($doc-path)
  return
    util:document-id($doc)
};

declare
    %test:args("/db/docid.xml")
    %test:assertEquals(7)
    %test:args("/db/test-docid/docid.xml")
    %test:assertEquals(8)
    %test:args("/db/no-such-document.xml")
    %test:assertEmpty
function docid:document-id-from-path($doc-path as xs:string) {
  util:document-id($doc-path)
};

error: pathspec 'exist-core/src/test/xquery/util/document-id.xqm' did not match any file(s) known to git


Add BaseX RESTXQ Module function signatures.

xquery version "3.0";
(:~
: BaseX RESTXQ Module functions
:
: @see http://docs.basex.org/wiki/RESTXQ_Module
:
:)
module namespace restxq = "http://exquery.org/ns/restxq";

import module namespace a = "http://reecedunn.co.uk/xquery/annotations" at "res://reecedunn.co.uk/xquery/annotations.xqy";

declare namespace wadl = "http://wadl.dev.java.net/2009/02";

declare %a:since("basex", "7.7") function rest:base-uri() as xs:anyURI external;
declare %a:since("basex", "7.7") function rest:uri() as xs:anyURI external;
declare %a:since("basex", "7.7") function rest:wadl() as element(wadl:application) external;
declare %a:since("basex", "8.6") function rest:init() as empty-sequence() external;

error: pathspec 'src/main/resources/builtin/exquery.org/ns/restxq.xqy' did not match any file(s) known to git


Useful XQuery that can be used to receive generic invocations of GET/POST/PUT/DELETE. It will just wrap the request payload and return it, along with some other information. Used for testing of the httpclient extension module.

svn path=/trunk/eXist/; revision=6489

xquery version "1.0";

declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";
declare namespace util="http://exist-db.org/xquery/util";

declare function local:wrapData( $data, $method ) as element()
{
    let $timestamp := fn:current-dateTime()

    return
        <request>
            <method>{$method}</method>
            <payload xmlns="http://exist-db.org/xquery/httpclienttest">
                   { $data }
            </payload>
        </request>

};

let $method := request:get-method()

return
    if( $method eq "POST" or $method eq "PUT" ) then (
        let $payload := request:get-data()
        let $temp := response:set-header( "X-Test-Method", $method )
        return
            if( $payload )then (
                let $data := local:wrapData( $payload, $method )
                return
                    $data
            ) else (
               let $temp := response:set-status-code( 400 )
               return
                   <error>no data received</error>
            )
    ) else if ($method eq "GET" or $method eq "DELETE" ) then (
             let $temp := response:set-header( "X-Test-Method", $method )
             let $data := local:wrapData( "none", $method )
                return
                    $data
     ) else if ($method eq "HEAD" or $method eq "OPTIONS" ) then (
        let $temp := response:set-header( "X-Test-Method", $method )
        return ()
    ) else (
        let $temp := response:set-status-code( 405 )
        let $temp := response:set-header( "Allow", "GET POST PUT DELETE HEAD OPTIONS" )
        return
        <error>Invalid HTTP Method: {$method}</error>
    )

error: pathspec 'webapp/xquery/httpclient-test.xql' did not match any file(s) known to git


added non functional group test

added non functional group test

xquery version "3.0";

module namespace groupa="http://exist-db.org/mongodb/test/group";

import module namespace xqjson = "http://xqilla.sourceforge.net/lib/xqjson";

import module namespace test="http://exist-db.org/xquery/xqsuite"
                at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

import module namespace mongodb = "http://exist-db.org/xquery/mongodb"
                at "java:org.exist.mongodb.xquery.MongodbModule";

import module namespace support = "http://exist-db.org/ext/mongodb/test/support"
                at "./support.xqm";

(:
 :  example taken from http://docs.mongodb.org/manual/core/map-reduce/
 :)

(: Connect to mongodb, store token :)
declare %test:setUp function groupa:setup()
{
    let $setup := support:setup()
    let $mongodbClientId := support:getToken()

    return(mongodb:insert($mongodbClientId, $support:database, $support:mongoCollection,
                          ('{ cust_id : "A123" , amount : 500 , status : "A"  }',
                          '{ cust_id : "A123" , amount : 250 , status : "A"  }',
                          '{ cust_id : "B212" , amount : 200 , status : "A"  }',
                          '{ cust_id : "A123" , amount : 300 , status : "D"  }')))

};

(: Disconnect from mongodb, cleanup token :)
declare %test:tearDown function groupa:cleanup()
{
    support:cleanup()
};

(: ----------------------------
 : Actual tests below this line
 : ---------------------------- :)

(:
 : collection#map-reduce()  simple
 :)
declare
    %test:assertEquals("A123", "750.0", "B212", "200.0")
function groupa:group_simple() {
    let $mongodbClientId := support:getToken()

    let $result := mongodb:group($mongodbClientId, $support:database, $support:mongoCollection,
                "{ cust_id : 1 , amount : 1 , status : 1}",
                "{ status : 'A'}",
                "{ total : 0 }",
                "function ( curr, result ) {
                     result.total += curr.amount;
                  }"

                    )

   return $result

};

error: pathspec 'java/test/src/org/exist/mongodb/test/group.xql' did not match any file(s) known to git


Adding controller.xql for url rewriting

Adding controller.xql for url rewriting

xquery version "1.0";
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace request="http://exist-db.org/xquery/request";

declare variable $exist:root external;
declare variable $exist:prefix external;
declare variable $exist:controller external;
declare variable $exist:path external;
declare variable $exist:resource external;

if ($exist:path eq '/') then
    let $msg := 'index'
    return
        <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
            <forward url="/index.xhtml">
            </forward>
        </dispatch>

else
if (starts-with($exist:path, '/edit/')) then
    let $item := substring-after($exist:path, 'edit/')
    return
        <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
            <forward url="/xq/xform-runner.xquery">
             <add-parameter name="fid" value="{$item}"/>
            </forward>
        </dispatch>

 else
 if (starts-with($exist:path, '/create')) then
 let $item := 'blank_template.xml'
 return
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
            <forward url="/xq/xform-runner.xquery">
             <add-parameter name="fid" value="{$item}"/>
            </forward>
   </dispatch>

   (: Let everything else pass through :)
else
    <ignore xmlns="http://exist.sourceforge.net/NS/exist">
        <cache-control cache="yes"/>
    </ignore>

error: pathspec 'controller.xql' did not match any file(s) known to git


Convert PROIEL to Treedown XML.

Convert PROIEL to Treedown XML.

declare function local:unwrap($t, $stok)
{
  let $children :=  $stok[@head-id = $t/@id]
  let $seq := ($children | $t)/.
  return
    if ($children)
    then
      <wg relation="{$t/@relation}">
        {
          for $s in $seq
          return
            if ($s is $t)
            then $t
            else local:unwrap($s, $stok)
        }
      </wg>
    else $t
};

for $s in //sentence
let $stok := $s//token
let $t := $stok[not(@head-id)][1]  (: hack ... get rid of subscript :)
return
  <sentence>
    {
      local:unwrap($t, $stok)
    }
  </sentence>

error: pathspec 'xquery/proiel2treedown.xquery' did not match any file(s) known to git


Builtin Definitions : XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)

(: XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)
 : W3C Recommendation 14 December 2010
 :
 : Reference: https://www.w3.org/TR/2010/REC-xpath-functions-20101214/
 :)
xquery version "3.0";

module  namespace fn = "http://www.w3.org/2005/xpath-functions";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";

declare %private type numeric = ( xs:integer | xs:decimal | xs:float | xs:double );

declare function fn:QName($paramURI as xs:string?, $paramQName as xs:string) as xs:QName external; (: §11.1.2 :)
declare function fn:abs($arg as numeric?) as numeric? external; (: §6.4.1 :)
declare function fn:adjust-date-to-timezone($arg as xs:date?) as xs:date? external; (: §10.7.2 :)
declare function fn:adjust-date-to-timezone($arg as xs:date?, $timezone as xs:dayTimeDuration?) as xs:date? external; (: §10.7.2 :)
declare function fn:adjust-dateTime-to-timezone($arg as xs:dateTime?) as xs:dateTime? external; (: §10.7.1 :)
declare function fn:adjust-dateTime-to-timezone($arg as xs:dateTime?, $timezone as xs:dayTimeDuration?) as xs:dateTime? external; (: §10.7.1 :)
declare function fn:adjust-time-to-timezone($arg as xs:time?) as xs:time? external; (: §10.7.3 :)
declare function fn:adjust-time-to-timezone($arg as xs:time?, $timezone as xs:dayTimeDuration?) as xs:time? external; (: §10.7.3 :)
declare function fn:avg($arg as xs:anyAtomicType*) as xs:anyAtomicType? external; (: §15.4.2 :)
declare function fn:base-uri() as xs:anyURI? external; (: §2.5 :)
declare function fn:base-uri($arg as node()?) as xs:anyURI? external; (: §2.5 :)
declare function fn:boolean($arg as item()*) as xs:boolean external; (: §15.1.1 :)
declare function fn:ceiling($arg as numeric?) as numeric? external; (: §6.4.2 :)
declare function fn:codepoint-equal($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean? external; (: §7.3.3 :)
declare function fn:codepoints-to-string($arg as xs:integer*) as xs:string external; (: §7.2.1 :)
declare function fn:collection() as node()* external; (: §15.5.6 :)
declare function fn:collection($arg as xs:string?) as node()* external; (: §15.5.6 :)
declare function fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer? external; (: §7.3.2 :)
declare function fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer? external; (: §7.3.2 :)
declare %variadic("xs:anyAtomicType?") function fn:concat($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?) as xs:string external; (: §7.4.1 :)
declare function fn:contains($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean external; (: §7.5.1 :)
declare function fn:contains($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean external; (: §7.5.1 :)
declare function fn:count($arg as item()*) as xs:integer external; (: §15.4.1 :)
declare function fn:current-date() as xs:date external; (: §16.4 :)
declare function fn:current-dateTime() as xs:dateTime external; (: §16.3 :)
declare function fn:current-time() as xs:time external; (: §16.5 :)
declare function fn:data($arg as item()*) as xs:anyAtomicType* external; (: §2.4 :)
declare function fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime? external; (: §5.2 :)
declare function fn:day-from-date($arg as xs:date?) as xs:integer? external; (: §10.5.16 :)
declare function fn:day-from-dateTime($arg as xs:dateTime?) as xs:integer? external; (: §10.5.9 :)
declare function fn:days-from-duration($arg as xs:duration?) as xs:integer? external; (: §10.5.3 :)
declare function fn:deep-equal($parameter1 as item()*, $parameter2 as item()*) as xs:boolean external; (: §15.3.1 :)
declare function fn:deep-equal($parameter1 as item()*, $parameter2 as item()*, $collation as string) as xs:boolean external; (: §15.3.1 :)
declare function fn:default-collation() as xs:string external; (: §16.7 :)
declare function fn:distinct-values($arg as xs:anyAtomicType*) as xs:anyAtomicType* external; (: §15.1.6 :)
declare function fn:distinct-values($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType* external; (: §15.1.6 :)
declare function fn:doc($uri as xs:string?) as document-node()? external; (: §15.5.4 :)
declare function fn:doc-available($uri as xs:string?) as xs:boolean external; (: §15.5.5 :)
declare function fn:document-uri($arg as node()?) as xs:anyURI? external; (: §2.6 :)
declare function fn:element-with-id($arg as xs:string*) as element()* external; (: §15.5.7 :)
declare function fn:element-with-id($arg as xs:string*, $node as node()) as element()* external; (: §15.5.7 :)
declare function fn:empty($arg as item()*) as xs:boolean external; (: §15.1.4 :)
declare function fn:encode-for-uri($uri-part as xs:string?) as xs:string external; (: §7.4.10 :)
declare function fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean external; (: §7.5.3 :)
declare function fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean external; (: §7.5.3 :)
declare function fn:error() as none external; (: §3 :)
declare function fn:error($error as xs:QName) as none external; (: §3 :)
declare function fn:error($error as xs:QName?, $description as xs:string) as none external; (: §3 :)
declare function fn:error($error as xs:QName?, $description as xs:string, $error-object as item()*) as none external; (: §3 :)
declare function fn:escape-html-uri($uri as xs:string?) as xs:string external; (: §7.4.12 :)
declare function fn:exactly-one($arg as item()*) as item() external; (: §15.2.3 :)
declare function fn:exists($arg as item()*) as xs:boolean external; (: §15.1.5 :)
declare function fn:false() as xs:boolean external; (: §9.1.2 :)
declare function fn:floor($arg as numeric?) as numeric? external; (: §6.4.3 :)
declare function fn:hours-from-dateTime($arg as xs:dateTime?) as xs:integer? external; (: §10.5.10 :)
declare function fn:hours-from-duration($arg as xs:duration?) as xs:integer? external; (: §10.5.4 :)
declare function fn:hours-from-time($arg as xs:time?) as xs:integer? external; (: §10.5.18 :)
declare function fn:id($arg as xs:string*) as element()* external; (: §15.5.2 :)
declare function fn:id($arg as xs:string*, $node as node()) as element()* external; (: §15.5.2 :)
declare function fn:idref($arg as xs:string*) as node()* external; (: §15.5.3 :)
declare function fn:idref($arg as xs:string*, $node as node()) as node()* external; (: §15.5.3 :)
declare function fn:implicit-timezone() as xs:dayTimeDuration external; (: §16.6 :)
declare function fn:in-scope-prefixes($element as element()) as xs:string* external; (: §11.2.6 :)
declare function fn:index-of($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType) as xs:integer* external; (: §15.1.3 :)
declare function fn:index-of($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType, $collation as xs:string) as xs:integer* external; (: §15.1.3 :)
declare function fn:insert-before($target as item()*, $position as xs:integer, $inserts as item()*) as item()* external; (: §15.1.7 :)
declare function fn:iri-to-uri($iri as xs:string?) as xs:string external; (: §7.4.11 :)
declare function fn:lang($testlang as xs:string?) as xs:boolean external; (: §14.5 :)
declare function fn:lang($testlang as xs:string?, $node as node()) as xs:boolean external; (: §14.5 :)
declare function fn:last() as xs:integer external; (: §16.2 :)
declare function fn:local-name() as xs:string external; (: §14.2 :)
declare function fn:local-name($arg as node()?) as xs:string external; (: §14.2 :)
declare function fn:local-name-from-QName($arg as xs:QName?) as xs:NCName? external; (: §11.2.3 :)
declare function fn:lower-case($arg as xs:string?) as xs:string external; (: §7.4.8 :)
declare function fn:matches($input as xs:string?, $pattern as xs:string) as xs:boolean external; (: §7.6.2 :)
declare function fn:matches($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean external; (: §7.6.2 :)
declare function fn:max($arg as xs:anyAtomicType*) as xs:anyAtomicType? external; (: §15.4.3 :)
declare function fn:max($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType? external; (: §15.4.3 :)
declare function fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType? external; (: §15.4.4 :)
declare function fn:min($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType? external; (: §15.4.4 :)
declare function fn:minutes-from-dateTime($arg as xs:dateTime?) as xs:integer? external; (: §10.5.11 :)
declare function fn:minutes-from-duration($arg as xs:duration?) as xs:integer? external; (: §10.5.5 :)
declare function fn:minutes-from-time($arg as xs:time?) as xs:integer? external; (: §10.5.19 :)
declare function fn:month-from-date($arg as xs:date?) as xs:integer? external; (: §10.5.15 :)
declare function fn:month-from-dateTime($arg as xs:dateTime?) as xs:integer? external; (: §10.5.8 :)
declare function fn:months-from-duration($arg as xs:duration?) as xs:integer? external; (: §10.5.2 :)
declare function fn:name() as xs:string external; (: §14.1 :)
declare function fn:name($arg as node()?) as xs:string external; (: §14.1 :)
declare function fn:namespace-uri() as xs:anyURI external; (: §14.3 :)
declare function fn:namespace-uri($arg as node()?) as xs:anyURI external; (: §14.3 :)
declare function fn:namespace-uri-for-prefix($prefix as xs:string?, $element as element()) as xs:anyURI? external; (: §11.2.5 :)
declare function fn:namespace-uri-from-QName($arg as xs:QName?) as xs:anyURI? external; (: §11.2.4 :)
declare function fn:nilled($arg as node()?) as xs:boolean? external; (: §2.2 :)
declare function fn:node-name($arg as node()?) as xs:QName? external; (: §2.1 :)
declare function fn:normalize-space() as xs:string external; (: §7.4.5 :)
declare function fn:normalize-space($arg as xs:string?) as xs:string external; (: §7.4.5 :)
declare function fn:normalize-unicode($arg as xs:string?) as xs:string external; (: §7.4.6 :)
declare function fn:normalize-unicode($arg as xs:string?, $normalizationForm as xs:string) as xs:string external; (: §7.4.6 :)
declare function fn:not($arg as item()*) as xs:boolean external; (: §9.3.1 :)
declare function fn:number() as xs:double external; (: §14.4 :)
declare function fn:number($arg as xs:anyAtomicType?) as xs:double external; (: §14.4 :)
declare function fn:one-or-more($arg as item()*) as item()+ external; (: §15.2.2 :)
declare function fn:position() as xs:integer external; (: §16.1 :)
declare function fn:prefix-from-QName($arg as xs:QName?) as xs:NCName? external; (: §11.2.2 :)
declare function fn:remove($target as item()*, $position as xs:integer) as item()* external; (: §15.1.8 :)
declare function fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string external; (: §7.6.3 :)
declare function fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string external; (: §7.6.3 :)
declare function fn:resolve-QName($qname as xs:string?, $element as element()) as xs:QName? external; (: §11.1.1 :)
declare function fn:resolve-uri($relative as xs:string?) as xs:anyURI? external; (: §8.1 :)
declare function fn:resolve-uri($relative as xs:string?, $base as xs:string) as xs:anyURI? external; (: §8.1 :)
declare function fn:reverse($arg as item()*) as item()* external; (: §15.1.9 :)
declare function fn:root() as node() external; (: §14.9 :)
declare function fn:root($arg as node()?) as node()? external; (: §14.9 :)
declare function fn:round($arg as numeric?) as numeric? external; (: §6.4.4 :)
declare function fn:round-half-to-even($arg as numeric?) as numeric? external; (: §6.4.5 :)
declare function fn:round-half-to-even($arg as numeric?, $precision as xs:integer) as numeric? external; (: §6.4.5 :)
declare function fn:seconds-from-dateTime($arg as xs:dateTime?) as xs:decimal? external; (: §10.5.12 :)
declare function fn:seconds-from-duration($arg as xs:duration?) as xs:decimal? external; (: §10.5.6 :)
declare function fn:seconds-from-time($arg as xs:time?) as xs:decimal? external; (: §10.5.20 :)
declare function fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean external; (: §7.5.2 :)
declare function fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean external; (: §7.5.2 :)
declare function fn:static-base-uri() as xs:anyURI? external; (: §16.8 :)
declare function fn:string() as xs:string external; (: §2.3 :)
declare function fn:string($arg as item()?) as xs:string external; (: §2.3 :)
declare function fn:string-join($arg1 as xs:string*, $arg2 as xs:string) as xs:string external; (: §7.4.2 :)
declare function fn:string-length() as xs:integer external; (: §7.4.4 :)
declare function fn:string-length($arg as xs:string?) as xs:integer external; (: §7.4.4 :)
declare function fn:string-to-codepoints($arg as xs:string?) as xs:integer* external; (: §7.2.2 :)
declare function fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double) as item()* external; (: §15.1.10 :)
declare function fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double, $length as xs:double) as item()* external; (: §15.1.10 :)
declare function fn:substring($sourceString as xs:string?, $startingLoc as xs:double) as xs:string external; (: §7.4.3 :)
declare function fn:substring($sourceString as xs:string?, $startingLoc as xs:double, $length as xs:double) as xs:string external; (: §7.4.3 :)
declare function fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?) as xs:string external; (: §7.5.5 :)
declare function fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string external; (: §7.5.5 :)
declare function fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?) as xs:string external; (: §7.5.4 :)
declare function fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string external; (: §7.5.4 :)
declare function fn:sum($arg as xs:anyAtomicType*) as xs:anyAtomicType external; (: §15.4.5 :)
declare function fn:sum($arg as xs:anyAtomicType*, $zero as xs:anyAtomicType?) as xs:anyAtomicType? external; (: §15.4.5 :)
declare function fn:timezone-from-date($arg as xs:date?) as xs:dayTimeDuration? external; (: §10.5.17 :)
declare function fn:timezone-from-dateTime($arg as xs:dateTime?) as xs:dayTimeDuration? external; (: §10.5.13 :)
declare function fn:timezone-from-time($arg as xs:time?) as xs:dayTimeDuration? external; (: §10.5.21 :)
declare function fn:tokenize($input as xs:string?, $pattern as xs:string) as xs:string* external; (: §7.6.4 :)
declare function fn:tokenize($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string* external; (: §7.6.4 :)
declare function fn:trace($value as item()*, $label as xs:string) as item()* external; (: §4 :)
declare function fn:translate($arg as xs:string?, $mapString as xs:string, $transString as xs:string) as xs:string external; (: §7.4.9 :)
declare function fn:true() as xs:boolean external; (: §9.1.1 :)
declare function fn:unordered($sourceSeq as item()*) as item()* external; (: §15.1.11 :)
declare function fn:upper-case($arg as xs:string?) as xs:string external; (: §7.4.7 :)
declare function fn:year-from-date($arg as xs:date?) as xs:integer? external; (: §10.5.14 :)
declare function fn:year-from-dateTime($arg as xs:dateTime?) as xs:integer? external; (: §10.5.7 :)
declare function fn:years-from-duration($arg as xs:duration?) as xs:integer? external; (: §10.5.1 :)
declare function fn:zero-or-one($arg as item()*) as item()? external; (: §15.2.1 :)

error: pathspec 'src/main/resources/builtin/REC-xpath-functions-20101214/fn.xqy' did not match any file(s) known to git


added hashjoin test

added hashjoin test

declare namespace lib = "lib";

declare function lib:pick($map as node()*, $repl as node()*) as node()*
{
  for $rec in $map/*
  return
    if ( $repl[name() eq name($rec)] )
    then ()
    else $rec
};

lib:pick((, <c/>, <x><x1/><x2/></x>), ())

error: pathspec 'test/rbkt/Queries/zorba/hashjoins/idx3.xq' did not match any file(s) known to git


Display xref information.

Display xref information.


Added xq file expressing query 6 using XQuery

Web data management & xml (CSE 5335)/Programming assignment 7/Individual queries/6.xq


Display more information for each term.

Display more information for each term.


Added example for dynamic constructors.

Added example for dynamic constructors.

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

declare namespace x="http://www.x.de";

declare namespace f="urn:test";

declare function f:copyChildren($node as node()) as node()+ {
	($node/@*, for $n in $node/* return f:copy($n))
};

declare function f:copy($node as node()) as node()+ {
	if($node instance of element()) then (
		if(local-name($node) eq "para") then
			element p { f:copyChildren($node) }
		else
			element { node-name($node) } { f:copyChildren($node) }
	) else
		$node
};

<html>
	{f:copy(root(doc("/db/test/test.xml")))}
</html>

error: pathspec 'samples/xquery/dynamic.xq' did not match any file(s) known to git


Add standalone example

Add standalone example

xquery version "3.0";

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

declare option output:method "html";

let $tpl := function($name) {
  xf:html-resource(file:base-dir() || $name)
}

let $list1 :=
  <list>
    <item>One</item>
    <item>Two</item>
    <item>Three</item>
  </list>

let $list2 :=
  <list>
    <item>A</item>
    <item>B</item>
    <item>C</item>
    <item>D</item>
  </list>

(: this model function can only be arity 0 to 4, a reasonable limit, otherwise pass an array or map :)
let $nav-model := function($list as element(list)) {

    ['span[@class="count"]',
        xf:content(text { count($list/item) }) ],

    ['div[text()][1]',
        xf:replace(for $item in $list/item return <div>{ string($item) }</div>) ],

    ['div[text()]',
        () ]
}

let $nav1 := xf:template($tpl('navs.html'), ['div[@id="nav1"]'], $nav-model)
let $nav2 := xf:template($tpl('navs.html'), ['div[@id="nav2"]'], $nav-model)
let $nav3 := xf:template($tpl('navs.html'), ['div[@id="nav3"]'], $nav-model)

let $base :=
    xf:template(
        $tpl('base.html'),
        function($context as map(*)?) {
            ['*[@id="title"]', xf:content(xf:text($context('title'))) ],
            ['*[@id="header"]', xf:content(xf:text($context('header'))) ],
            ['*[@id="main"]',  xf:content($context('main'))],
            ['*[@id="footer"]',  xf:content(xf:text($context('footer'))) ]
        }
    )

let $three-col :=
    xf:template(
        $tpl('3col.html'),
        ['div[@id="main"]'],
        function($left, $middle, $right) {
            ['div[@id="left"]', xf:content($left)],
            ['div[@id="middle"]', xf:content($middle)],
            ['div[@id="right"]', xf:content($right)]
        }
    )

let $viewa := function() {
  $base(
    map {
      'title': "View A",
      'main': $three-col((),(),())
    }
  )
}

let $viewb := function($left, $right) {
  $base(
    map {
      'title': "View B",
      'main': $three-col($left, (), $right)
    }
  )
}

let $viewc := function($action) {
  let $navs :=
    if ($action = 'reverse') then
      ($nav2, $nav1)
    else
      ($nav1, $nav2)
  return
    $base(
      map {
        'title': "View C",
        'header': "Templates a go-go",
        'footer': "Origami Template",
        'main': $three-col($navs[1]($list1), (), $navs[2]($list2))
      }
    )
}

let $index := function($context as map(*)?) {
  $base($context)
}

return
  (: $viewc(()) :)
  (: $viewc('reverse') :)
  (: $viewb($nav1($list2), $nav2($list1)) :)
  (: $viewa():)
  $index(
     map {
       'title': 'My Index',
       'header': 'A boring header',
       'footer': 'A boring footer',
       'main': $three-col($nav1($list1), $nav2($list2), $nav3($list1))
     })

error: pathspec 'examples/nolen.xq' did not match any file(s) known to git


Adding missing XQuery file for webtest

Adding missing XQuery file for webtest

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

xquery version "1.0";

declare option exist:serialize "method=xml";

import module namespace xdb="http://exist-db.org/xquery/xmldb";

let $home := util:system-property("exist.home")
let $sep := util:system-property("file.separator")
let $tempDir := concat($home, $sep, "test", $sep, "temp")
let $stored := xdb:store-files-from-pattern("/db/webtest", $tempDir, "**/*.xml", "text/xml", true())
return

        <title>XML:DB module functions test</title>

{count($stored)}

{$stored}

error: pathspec 'webapp/webtest/xmldb-module.xql' did not match any file(s) known to git


[test] Tests for computed namespace constructor

(:
 : 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.0";

(:~
 : Tests for Computed Namespace Constructors
 :)
module namespace cnc = "http://exist-db.org/xquery/test/computed-namespace-constructors";

import module namespace test = "http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

declare namespace ok="http://place-on-interwebz.com/a-ok";
declare namespace doh="http://also-on-interwebz.com/problem";

declare
    %test:assertError("XQDY0102")
function cnc:cannot-override-no-ns() {
    element root {namespace {""} {"http://also-on-interwebz.com/problem"},
        namespace ok {"http://place-on-interwebz.com/a-ok"},
        for $n in 1 to 3
        return
            element stuff {$n}
    }
};

declare
    %test:assertEquals(3)
function cnc:ns-default-constructor() {
    count(
        element ok:root {namespace {""} {"http://also-on-interwebz.com/problem"},
            namespace ok {"http://place-on-interwebz.com/a-ok"},
            for $n in 1 to 3
            return
                element stuff {$n}
        }/stuff
    )
};

error: pathspec 'exist-core/src/test/xquery/xquery3/computed-namespace-constructor.xql' did not match any file(s) known to git


layout the search XQuery script to look better in a blog article.

fatal: unable to access 'https://github.com/lcahlander/mysearch.git/': The requested URL returned error: 403


First example view

First example view

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

import module namespace log="http://cefn.com/readinglog/log" at "lib/log.xq";

log:webpage(
    for $doc in $log:collection return $doc//h1
)

error: pathspec 'ui/xq/untagged.xq' did not match any file(s) known to git


Added xq file expressing query 1 using XQuery

Web data management & xml (CSE 5335)/Programming assignment 7/Individual queries/1.xq


eXist builtin functions - add atomic.exist-db.org/xquery/atomic/theme

error: RPC failed; HTTP 403 curl 22 The requested URL returned error: 403
fatal: the remote end hung up unexpectedly


Tests for eXist's dialect of XQuery Update Facility

fatal: remote error: upload-pack: not our ref 57ce1ec2eefb938613f04c80fef50a9466832762
fatal: the remote end hung up unexpectedly


Added environment builder

Added environment builder

xquery version "3.0";

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

declare namespace x = 'urn:example';

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

(:~
 : In an empty environment the context will equal the nodes
 : passed into the environment function which you can then
 : query.
 :)
declare %unit:test %unit:ignore function test:empty-environment() {
    let $ctx := xf:env(
        map {}
    )
    let $eval := $ctx(<foo/>)
    return
        unit:assert-equals(
            $eval('.'),
            <foo/>
        )
};

(:~
 : If your query doesn't use a namespace then you do not have to
 : define it on the environment if the namespace nodes are already
 : present in the context nodes.
 :)
declare %unit:test %unit:ignore function test:namespace-on-nodes-environment() {
    let $ctx := xf:env(
        map {}
    )
    let $eval := $ctx(<x:foo/>)
    return (
        unit:assert-equals(
            $eval('.'),
            <x:foo/>
        )
    )
};

(:~
 : To declare functions or variables in your eval environment you need to
 : pass them in as a bindings map.
 : Note that you always have to pass in context nodes argument even if empty
 :)
declare %unit:test %unit:ignore function test:var-environment() {
    let $ctx := xf:env(
        map { 'bindings': map {'x': 10} }
    )
    let $eval := $ctx(())
    return
        unit:assert-equals(
            $eval('$x'),
            10
        )
};

error: pathspec 'test/test-environment.xqm' did not match any file(s) known to git


TEMP copied from eXist-db to solve path problem when running XQSuite tests from XSuite

xquery version "3.1";

import module namespace test = "http://exist-db.org/xquery/xqsuite"
    at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";

declare variable $test-module-uri as xs:anyURI external;

(: hooks for sending external notifications about test events :)
declare variable $test-ignored-function as (function(xs:string) as empty-sequence())? external;
declare variable $test-started-function as (function(xs:string) as empty-sequence())? external;
declare variable $test-failure-function as (function(xs:string, map(xs:string, item()?), map(xs:string, item()?)?) as empty-sequence())? external;
declare variable $test-assumption-failed-function as (function(xs:string, map(xs:string, item()?)) as empty-sequence())? external;
declare variable $test-error-function as (function(xs:string, map(xs:string, item()?)?) as empty-sequence())? external;
declare variable $test-finished-function as (function(xs:string) as empty-sequence())? external;

test:suite(
    inspect:module-functions($test-module-uri),
    $test-ignored-function, $test-started-function, $test-failure-function,
    $test-assumption-failed-function, $test-error-function, $test-finished-function
)

error: pathspec 'test/src/org/exist/test/runner/xquery-test-runner.xq' did not match any file(s) known to git


Remove dead code.

Remove dead code.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/julen/tzos.git/'


[ADD] exp. fots.xq script added to run michael h. kay's FOTS tests

(: global namespace of the test suite. :)
declare namespace fots = "http://www.w3.org/2010/09/qt-fots-catalog";

(: prefix of catalog to test. :)
declare variable $doc := doc('catalog.xml');
(: prefix of catalog to test. :)
declare variable $catalog := '';
(: prefix of tests to test. :)
declare variable $prefix := '';

(: loops throgh the test set and evaluates all test cases :)
declare function fots:main() {
  let $env := $doc//*:environment
  for $set in $doc//*:test-set[starts-with(@name, $catalog)]
  let $href := $set/@href
  let $base-dir := replace($href, '/.*','/')
  let $doc := doc($href)
  for $case in $doc//*:test-case[starts-with(@name, $prefix)]
  let $env := $env | $doc//*:environment
  return fots:test($case, $env, $base-dir)
};

(: runs a single test :)
declare function fots:test($case, $envir, $base) {
  let $query := $case/*:test/text()
  let $env := $envir[@name = $case/*:environment/@ref]/*:source/@file
  let $result := $case/*:result
  let $prolog :=
    if($env)
    then concat("declare context item := doc('",
     if(file:exists(concat($base, $env))) then $base else (), $env, "');")
    else ()
  let $query := concat($prolog, $query)
  return
  try {
    let $val := util:eval($query)
    return if
     (fots:allof($result, $val) or
      fots:anyof($result, $val) or
      fots:true($result, $val) or
      fots:false($result, $val) or
      fots:eq($result, $val) or
      fots:string($result, $val))
      then fots:wrong($case, $val, $result/*)
      else ()
  } catch *($code, $msg) {
    if(xs:string($code) = $result//*:error/@code)
    then ()
    else fots:wrong($case, concat($code,': ',$msg), $result/*)
  }
};

(: gives feedback on an erroneous query :)
declare function fots:wrong($test, $found, $exp) {
  <test name="{ $test/@name }">
    <query>{ $test/*:test/text() }</query>
    <found>{ $found }</found>
    <expected>{
      if($exp/self::*:error)
      then data($exp/@code)
      else $exp
    }</expected>
  </test>
};

(: converts a value to the specified type :)
declare function fots:convert($type, $val) {
  if($type)
  then
    try {
      util:eval(concat($type, '("', $val, '")'))
    } catch *($c,$m) {
      trace('', concat($c, ': ', $m))
    }
  else $val
};

(: checks if any of the given tests is wrong :)
declare function fots:allof($result, $val) {
  let $type := $result//*:assert-type
  let $val := fots:convert($type, $val)
  for $c in $result/*:all-of/*
  let $eq := replace($c/self::*:assert-eq, "^('|"")|('|"")$", "")
  return
    if(not($eq) or fots:convert($type, $eq) eq $val)
    then ()
    else false()
};

(: checks if none of the given tests is true :)
declare function fots:anyof($result, $val) {
  let $type := $result//*:assert-type
  let $val := fots:convert($type, $val)
  let $ok :=
    for $c in $result/*:any-of/*
    return if(
      not(fots:true($c, $val)) and
      not(fots:false($c, $val)) and
      not(fots:string($c, $val)))
      then true()
      else ()
  return exists($result/*:any-of) and empty($ok)
};

(: checks if the given value is not true :)
declare function fots:true($result, $val) {
  $result/*:assert-true and not($val)
};

(: checks if the given value is not false :)
declare function fots:false($result, $val) {
  $result/*:assert-false and $val
};

(: checks if the given string is wrong :)
declare function fots:string($result, $val) {
  $result/*:assert-string-value ne string($val)
};

(: checks if the equality yields false :)
declare function fots:eq($result, $val) {
  for $i in $result/*:assert-eq
  return
    try {
      let $r := util:eval($i)
      return (typeswitch($val)
        case xs:string  return xs:string($r)
        case xs:double  return xs:double($r)
        case xs:float   return xs:float($r)
        case xs:integer return xs:integer($r)
        default return $val) ne $val
    } catch *($c,$m) {
      trace('', concat($c, ': ', $m))
    }
};

(: runs the main function :)
fots:main()

error: pathspec 'etc/xq/fots.xq' did not match any file(s) known to git


Stub module for logging support

Stub module for logging support

(: =====================================================

   DFST Logging Module

   Manages logging of operations.

   The logging facility allows for reporting of operations
   done during updating functions by storing logs and
   then providing access to those logs after the fact.

   Because XQuery does not allow updating functions to
   return anything, there is no direct way for updating
   functions to return a status.

   Author: W. Eliot Kimber

   Copyright (c) 2015 DITA For Small Teams
   Licensed under Apache License 2

   ===================================================== :)

module namespace log="http://dita-for-small-teams.org/xquery/modules/logger";

(: TBD: Implement required logging functions :)

(: End of Module :)

error: pathspec 'modules/org/dita-for-small-teams/xquery/modules/logger.xqm' did not match any file(s) known to git


XQuery for abstract

XQuery for abstract

<pubmed>
<PMID>
{data(//MedlineCitation/PMID)}
</PMID>
<date>
{data(//MedlineCitation/DateCompleted/Year)}
</date>
<title>
{data(//MedlineCitation/Article/ArticleTitle)}
</title>
<journal>
{data(//MedlineCitation/Article/Journal/Title)}
</journal>
<author>
{data(//AuthorList/Author[1]/LastName)}
</author>
<abstract>
{data(//AbstractText)}
</abstract>
</pubmed>

error: pathspec 'thalemine/webapp/resources/pubmed.xq' did not match any file(s) known to git


Add xf:query tests

Add xf:query tests

xquery version "3.0";

(:~
 : Origami tests: xf:query
 :
 : NOTE: this way of querying is very slow and doesn't add much
 :       over regular XQuery code, also, I'm not sure if this function
 :       should be part of Origami.
 :)
module namespace test = 'http://xokomola.com/xquery/origami/tests';

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

declare %unit:test function test:query-default-env() {
    unit:assert-equals(
        xf:query('self::p/@name', xf:context(
)),
        attribute name { 'foo' }
    ),
    unit:assert-equals(
        xf:query('self::html:p/@name', xf:context(
)),
        attribute name { 'foo' }
    ),
    unit:assert-equals(
        xf:query('self::html:p/@name', xf:context(<foo:p name="foo" xmlns:foo="http://www.w3.org/1999/xhtml"/>)),
        attribute name { 'foo' }
    ),
    unit:assert-equals(
        xf:query('self::html:p/@name', xf:context(<foo:p name="foo" xmlns:foo="urn:foo"/>)),
        ()
    )
};

declare %unit:test function test:query-env() {
    unit:assert-equals(
        xf:query('self::p/@name', xf:context(
, xf:env((xf:ns('foo', 'urn:foo'))))),
        attribute name { 'foo' }
    ),
    unit:assert-equals(
        xf:query('self::foo:p/@name', xf:context(
, xf:env((xf:ns('foo', 'urn:foo'))))),
        ()
    ),
    unit:assert-equals(
        xf:query('self::foo:p/@name', xf:context(
, xf:env((xf:ns('foo', 'urn:foo'))))),
        attribute name { 'foo' }
    )
};

(:~
 : NOTE: test timings indicate that it's as slow as the above.
 : query-default-env: 0.27s, query-env: 0.2s, query-compiled: 0.26s
 :
 : NOTE: I could take namespaces from the context nodes but that would
 : still pose a problem fro default namespace as it doesn't have a prefix.
 : Therefore, I think it's cleaner to have to explicitly specify them in
 : the environment.
 :)
declare %unit:test function test:query-compiled() {
    let $q := xf:query(xf:context(
, xf:env((xf:ns('foo', 'urn:foo')))))
    return (
        unit:assert-equals(
            $q('self::foo:p/@name'),
            attribute name { 'foo' }
        ),
        unit:assert-equals(
            $q('count(".")'),
            1
        ),
        unit:assert-equals(
            $q('count(".//@*")'),
            1
        ),
        (: NOTE: this does not return foo:p as the prefix isn't in scope for the context node :)
        unit:assert-equals(
            $q('name(.)'),
            'p'
        )
    )
};

error: pathspec 'test/test-query.xqm' did not match any file(s) known to git


Add BaseX Profiling Module function signatures.

xquery version "3.0";
(:~
: BaseX Profiling Module functions
:
: @see http://docs.basex.org/wiki/Profiling_Module
:)
module namespace prof = "http://basex.org/modules/prof";

import module namespace a = "http://reecedunn.co.uk/xquery/annotations" at "res://reecedunn.co.uk/xquery/annotations.xqy";

declare %a:since("basex", "9.0") function prof:track($expression as item()) as item()* external;
declare %a:since("basex", "9.0") function prof:track($expression as item(), $options as map(*)?) as item()* external;
declare %a:since("basex", "7.3") function prof:time($expr as item()) as item()* external;
declare %a:since("basex", "7.3") %a:until("basex", "9.0") function prof:time($expr as item(), $cache as xs:boolean) as item()* external;
declare %a:since("basex", "7.3") %a:until("basex", "9.0") function prof:time($expr as item(), $cache as xs:boolean, $label as xs:string) as item()* external;
declare %a:since("basex", "7.3") function prof:time($expr as item(), $label as xs:string) as item()* external;
declare %a:since("basex", "7.3") function prof:memory($expr as item()) as item()* external;
declare %a:since("basex", "7.3") function prof:memory($expr as item(), $label as xs:string) as item()* external;
declare %a:since("basex", "7.5") function prof:current-ms() as xs:integer external;
declare %a:since("basex", "7.5") function prof:current-ns() as xs:integer external;
declare %a:since("basex", "7.5") function prof:dump($expr as item()) as empty-sequence() external;
declare %a:since("basex", "7.5") function prof:dump($expr as item(), $label as xs:string) as empty-sequence() external;
declare %a:since("basex", "8.1") function prof:variables() as empty-sequence() external;
declare %a:since("basex", "8.5") function prof:type($expr as item()*) as item()* external;
declare %a:since("basex", "7.7") function prof:void($value as item()*) as empty-sequence() external;
declare %a:since("basex", "7.3") function prof:sleep($ms as xs:integer) as empty-sequence() external;
declare %a:since("basex", "7.6") function prof:human($number as xs:integer) as xs:string external;

error: pathspec 'src/main/resources/builtin/basex.org/modules/prof.xqy' did not match any file(s) known to git


Added small test to check access to range index.

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

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

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

declare function f:term-callback($term, $data as xs:int+) as element() {
	<entry>
		<frequency>{$data[1]}</frequency>
		<documents>{$data[2]}</documents>
		<term>{$term}</term>
	</entry>
};

<entries>
	<cities>
	{
		util:index-keys(//city/name, "T", util:function("f:term-callback", 2), 1000)
	}
	</cities>
	<population>
	{
		util:index-keys(//city/population, 1, util:function("f:term-callback", 2), 1000)
	}
	</population>
</entries>

error: pathspec 'webapp/webtest/scan-range-index.xql' did not match any file(s) known to git


eXist builtin functions - add atomic.exist-db.org/xquery/atomic/search

xquery version "3.0";
(:~
 : eXist-db atomic search functions
 :
 : @see http://exist-db.org/exist/apps/fundocs/view.html?uri=http://atomic.exist-db.org/xquery/atomic/search&location=/db/apps/wiki/modules/search.xql&details=true
 :
 :)
module namespace search ="http://atomic.exist-db.org/xquery/atomic/search";

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 search:do-query($context as node()*, $query as xs:string, $field as xs:string) as item()* external;
declare %a:since("exist", "4.4") function search:entry-id($node as node()) as item()* external;
declare %a:since("exist", "4.4") function search:get-entry($node as node(), $model as map(*)) as item()* external;
declare %a:since("exist", "4.4") function search:kwic($node as node(), $model as map(*)) as item()* external;
declare %a:since("exist", "4.4") function search:query($node as node()*, $model as map(*), $q as xs:string?, $field as xs:string, $view as xs:string) as item()* external;
declare %a:since("exist", "4.4") function search:result-count($node as node(), $model as map(*)) as item()* external;
declare %a:since("exist", "4.4") function search:results($node as node(), $model as map(*)) as item()* external;
declare %a:since("exist", "4.4") function search:title($node as node(), $model as map(*)) as item()* external;

error: pathspec 'src/main/resources/builtin/atomic.exist-db.org/xquery/atomic/search.xqy' did not match any file(s) known to git


corrected minor failures

corrected minor failures

svn path=/trunk/eXist/; revision=12072

import module namespace http = "http://www.expath.org/mod/http-client" at "/db/scripts/http-client/http-client.xq";
declare namespace rb="http://kjc-fs1.kjc.uni-heidelberg.de/refbase";

(: credentials :)
declare variable $scope  := doc('/db/scripts/refbase/conf.xml');
declare variable $repository-name as xs:string := $scope/repositroy/name/string();
declare variable $database as xs:string := $scope/repositroy/driver/database/string();
declare variable $repository := concat($repository-name,"?repository=",$database,"&");
declare variable $username as xs:string := $scope/repositroy/driver/user/string();
declare variable $password as xs:string := $scope/repositroy/driver/password/string();
declare variable $collection := 'xmldb:exist:///db/mods/refbase/';
declare variable $file-name := 'refbase-metadata.xml';

(: the transform rule :)
declare function local:transform-serials($doc as document-node()) as document-node() {
 document {
   <modsCollection>
   {
     for $serial in $doc//rb:repository/sql:result/sql:row/sql:serial/string()
       return  local:transform-entries(local:get-in($serial))
   }
   </modsCollection>
 }
};

(:author (; nachnanem,vorname) title<titleInfo:title> year<originInfo:dateIssued> publisher<originInfo:c> place (;) <place:placeTerm>  isbn  <identifier type="isbn"> cluster_publication(note type="cp") :)
declare function local:transform-entries($doc as document-node()) as document-node() {
 document {

     for $serial in $doc//rb:repository/rb:id/sql:result/sql:row
      return
        <mods xmlns="http://www.loc.gov/mods/v3" version="3.4" ID="{$serial/sql:serial/string()}">
        <typeOfResource>text</typeOfResource>
        <titleInfo><title>{$serial/sql:title/string()}</title></titleInfo>

        {
        let $names := fn:tokenize($serial/sql:author/string(),';')
        for $name in $names
            return
             <name type="personal">
            <namePart type="given">{$name}</namePart>
        <role><roleTerm authority="marcrelator" type="text">author</roleTerm></role>
        </name>

        }
   (:use : retrieve mods functions , if avavailable:)
        <originInfo><dateIssued>{$serial/sql:year/string()}</dateIssued></originInfo>
        <originInfo><publisher>{$serial/sql:publisher/string()}</publisher></originInfo>
        <place><placeTerm>{$serial/sql:place/string()}</placeTerm></place>
        <identifier type="isbn">{$serial/sql:isbn/string()}</identifier>

   </mods>
   }

};

(: retrieve the input doc :)
declare function local:get-in($serial) as document-node() {
let $serial_id := concat('serial=',$serial)
 let $req := <http:request href="{$repository}{$serial_id}"
                           method="get"
                           username="{ $username }"
                           password="{ $password }"
                           auth-method="basic"
                           send-authorization="true"/>
   return
     (: error checking is left as an exercise :)
     http:send-request($req)[2]
};

(: save the document to database:)
declare function local:save-file($doc as document-node()) {
  let $login := xmldb:login($collection, $username, $password)
  let $store-return-status := xmldb:store($collection, $file-name, $doc)
  return 1
};

(: retrieve a doc, transform it and upload the result :)

let $serial  :=  xs:string(request:get-parameter('serial', ''))
return
<modsCollection>
{
if (not($serial))
 then (
  (:local:transform-serials(local:get-in($serial)) :)
  system:as-user($username,$password,local:save-file(local:transform-serials(local:get-in($serial))))
 )
 else (
  local:transform-entries(local:get-in($serial))
 )

}
</modsCollection>

error: pathspec 'webapp/biblio/repository/saveRepositoryIDs.xql' did not match any file(s) known to git


XQuery demo of the EXI extension functions [documentation]

svn path=/trunk/eXist/; revision=14681

xquery version "1.0";

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

declare option exist:serialize "media-type=application/xml";

(: round trip demo :)

let $xml :=
<ForecastList>
    <Forecast>
        <SiteId>34567</SiteId>
        <TimeStep>2011-06-13T12:00:00Z</TimeStep>
        <WeatherElement name="WindSpeed" uom="mps">11.2</WeatherElement>
        <WeatherElement name="ScreenTemperature"> uom="degC">16.4</WeatherElement>
        <WeatherElement name="Visibility" uom="metres">6000.0</WeatherElement>
    </Forecast>
</ForecastList>,
$exi := exi:encode-from-xml($xml) return
exi:decode-to-xml($exi)

error: pathspec 'extensions/modules/src/org/exist/xquery/modules/exi/exi-functions-demo.xql' did not match any file(s) known to git


test: add testsuite for literals in curly braces

xquery version "3.1";

(:~
    These tests emerged from research regarding
    https://github.com/eXist-db/exist/issues/291

    The xquery-parser MUST recognize a curly brace expression,
    if it starts with a literal string.
~:)
module namespace litcurl="http://exist-db.org/xquery/test/literals-in-curlies";
declare namespace test="http://exist-db.org/xquery/xqsuite";

declare
    %test:pending
    %test:assertEquals("<root a='a'/>")
function litcurl:literalString() {
(:
 : Since the line below raises a static error, it cannot be tested yet.
 : When the xquery parser is fixed, uncomment it and remove the zero.
 : <root a="{'a'}"/>
 :)
    0
};

(:~ other literals ~:)
declare
    %test:assertEquals("<root a='true'/>")
function litcurl:literalBooleanTrue() {
    <root a="{true()}"/>
};

declare
    %test:assertEquals("<root a='false'/>")
function litcurl:literalBooleanFalse() {
    <root a="{false()}"/>
};

declare
    %test:assertEquals("<root a='0'/>")
function litcurl:literalNumberZero() {
    <root a="{0}"/>
};

declare
    %test:assertEquals("<root a='1'/>")
function litcurl:literalNumberOne() {
    <root a="{1}"/>
};
declare
    %test:assertEquals("<root a='-1'/>")
function litcurl:literalNumberNegativeOne() {
    <root a="{-1}"/>
};

declare
    %test:assertEquals("<root a='1.1111'/>")
function litcurl:literalDecimal() {
    <root a="{1.1111}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:typeConversionToString() {
    <root a="{xs:string('a')}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:concatStringWithEmptySequence() {
    <root a="{() || 'a'}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:sequenceWithOneLiteralString() {
    <root a="{('a')}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:firstArrayElement() {
    <root a="{['a']?1}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:variableSubstitution() {
    let $a := 'a'
    return <root a="{$a}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:stringConstructor() {
    <root a="{``[a]``}"/>
};

declare
    %test:assertEquals("<root a='a'/>")
function litcurl:mapProperty() {
    <root a="{map{'a':'a'}?a}"/>
};

error: pathspec 'test/src/xquery/literals-in-curlies.xql' did not match any file(s) known to git


context List service

context List service

xquery version "1.0";

(: ~
 : Module Name:             trial designer xml document
 :
 : Module Version           1.0
 :
 : Date                               31st October 2006
 :
 : Copyright                       The cagrid consortium
 :
 : Module overview          outputs the expected message for the trial designer plug-in
 :
 :)

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

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

declare namespace request="http://exist-db.org/xquery/request";
declare namespace session="http://exist-db.org/xquery/session";
declare namespace response="http://exist-db.org/xquery/response";

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

session:create(),
let $contextList := request:get-parameter("contextList", "")
return
    lib-search:contextList($contextList)

error: pathspec 'grid-incubation/incubator/projects/mdr/projects/mdrCore/db/mdr/services/contextList.xquery' did not match any file(s) known to git


Only display public translations.

Only display public translations.


adding edit organization

adding edit organization

xquery version "1.0";

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

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

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

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

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

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

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

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

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

   (: 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=editProperty.xquery&",$message)))
};

declare function local:input-page(
   $message as xs:string?,
   $id as xs:string?,
   $reg-auth as xs:string?,
   $administrative-note  as xs:string?,
   $administrative-status  as xs:string?,
   $administered-by  as xs:string?,
   $submitted-by  as xs:string?,
   $registered-by  as xs:string?,
   $context-ids  as xs:string*,
   $country-identifiers as xs:string*,
   $language-identifiers as xs:string*,
   $names as xs:string*,
   $definitions as xs:string*,
   $sources as xs:string*,
   $property_uri as xs:string?,
   $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 edit an Organisation in the metadata repository

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

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

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

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 Changes"/>	<input type="submit" name="update" value="Clear"/>

          </form>

{$message}

   };

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

Property modified

Return to maintenance menu

Create another 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 $id := request:get-parameter('id','')
   let $updating := request:get-parameter('updating','')
   let $title as xs:string := concat("Editing Organization ", $id)
   let $element := lib-util:mdrElement("organisation",$id)
   let $action := request:get-parameter('update','')

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

   let $iorganization_name :=element//openMDR:organization_name
   let $iorganization_mail_address :=element//openMDR:organization_mail_address
   let $icontact_name :=element//openMDR:contact_name
   let $icontact_title :=element//openMDR:contact_title
   let $icontact_information :=element//openMDR:contact_information

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

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

   return

      lib-rendering:txfrm-webpage(
      $title,
      if ($action='Store Changes')
      then
         (
         if (
               local:organisation
                  (
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $preferred,

                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information
                  )
            )
         then (local:success-page()  )
         else (local:input-page(
            'could not store document',
                     $id,
                     $reg-auth,
                     $administrative-note,
                     $administrative-status,
                     $administered-by,
                     $submitted-by,
                     $registered-by,
                     $context-ids,
                     $country-identifiers,
                     $language-identifiers,
                     $names,
                     $definitions,
                     $sources,
                     $property_uri,
                     $preferred,

                     $organization_name,
                     $organization_mail_address,
                     $contact_name,
                     $contact_title,
                     $contact_information,
                     $action
                  )
               )
         )
      else (
         if ($updating ='updating')
         then (
      local:input-page
               (
               '',
               $id,
               $reg-auth,
               $administrative-note,
               $administrative-status,
               $administered-by,
               $submitted-by,
               $registered-by,
               $context-ids,
               $country-identifiers,
               $language-identifiers,
               $names,
               $definitions,
               $sources,
               $property_uri,
               $preferred,

               $organization_name,
               $organization_mail_address,
               $contact_name,
               $contact_title,
               $contact_information,
               $action
               )
         ) else (
               local:input-page
               (
               '',
               $id,
               $ireg-auth,
               $iadministrative-note,
               $iadministrative-status,
               $iadministered-by,
               $isubmitted-by,
               $iregistered-by,
               $icontext-ids,
               $icountry-identifiers,
               $ilanguage-identifiers,
               $inames,
               $idefinitions,
               $isources,
               $iproperty_uri,
               $ipreferred,

               $iorganization_name,
               $iorganization_mail_address,
               $icontact_name,
               $icontact_title,
               $icontact_information,
               $action
               )
         )
       )

    )

error: pathspec 'grid-incubation/incubator/projects/mdr/projects/mdrCore/db/mdr/edit/editOrganisation.xquery' did not match any file(s) known to git


Added query to return results according to book, url or pdf

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 template="http://cefn.com/readinglog/template" at "/home/cefn/Documents/highwire/participatory firmware design/readinglog/scripts/server/xquery/lib/template.xq";
declare default element namespace "http://www.w3.org/1999/xhtml";

declare variable $type external;

template:webpage(

		{for $heading in notes:allnotes()[notes:sourcetype(.)=$type]//h1 return
{string($heading)}
}

)

error: pathspec 'scripts/server/xquery/sourcetype.xq' did not match any file(s) known to git


Properly display term classification.

Properly display term classification.