edit conceptual domain file...still needs to be modified

xquery version "1.0";

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

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

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

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

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

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

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

declare function local:conceptual_domain(
   $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?,
   $meanings as xs:string*
   ) as xs:boolean
{
   let $version := lib-forms:substring-after-last($id,'-')
   let $vmid := substring-after(lib-forms:substring-before-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),
                    for $m in $meanings
                    return
                    element openMDR:Value_Meaning
                       {
                       element openMDR:value_meaning_begin_date {current-date()},
                       element openMDR:value_meaning_description {$m},
                       element openMDR:value_meaning_identifier {$vmid}
                       }
                    )

   (: compose the document :)
   let $document := (
       if($meanings > '') then (
          element openMDR:Enumerated_Conceptual_Domain {
                attribute item_registration_authority_identifier {$reg-auth},
                attribute data_identifier {$data-identifier},
                attribute version {$version},
                $content
               }
      ) else (
          element openMDR:Non_Enumerated_Conceptual_Domain {
                attribute item_registration_authority_identifier {$reg-auth},
                attribute data_identifier {$data-identifier},
                attribute version {$version},
                $content
               }
      )
   )

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

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

          <form name="edit_value_domain" action="editConceptualDomain.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)}

Conceptual Domain

                {
                 if(request:get-parameter('conceptual-domain-type','') = 'enumerated') then (

Enumerated Conceptual Domain?
                      <input type="radio" name="conceptual-domain-type" value="enumerated" checked="checked">enumerated</input>
                      <input type="radio" name="conceptual-domain-type" value="non-enumerated">non-enumerated</input>
                      {lib-forms:action-button('update', 'action' ,'')}

,

Conceptual Domain Meanings
,

                      Value Domain Meanings	meaning

,

                        for $meaning at $pos in $meanings
                        let $location := if($pos > $skip-name-index and $skip-name-index > 0) then (util:eval($pos - 1)) else ($pos)
                        where $pos != $skip-name-index and $meaning > ""
                        return (

                              Value {$location} Meaning
                              {lib-forms:input-element('meanings', 60, $meaning)}
                              {lib-forms:action-button(concat('delete value meaning ',$location), 'action' ,'')}

                           ),

                              New Value Meaning
                              {lib-forms:input-element('meanings', 60, '')}
                              {lib-forms:action-button('add new value meaning', 'action' ,'')}

                 ) else (

Enumerated Conceptual Domain?
                           <input type="radio" name="conceptual-domain-type" value="enumerated" >enumerated</input>
                           <input type="radio" name="conceptual-domain-type" value="non-enumerated" checked="checked">non-enumerated</input>
                           {lib-forms:action-button('update', 'action' ,'')}

                 )
              }

Store

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

          </form>

{$message}

   };

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

Property modified

Return to maintenance menu

Create another property class

};

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

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

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

   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 $meanings := request:get-parameter('meanings','')

   return

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

    )

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


Add a new Query in the parser test suite for XQuery scripting.

import module namespace zorba =
  "http://www.zorba-xquery.com/zorba/internal-functions";

declare variable $nl := "
";

declare sequential function local:calc-one ($s as xs:string) as xs:boolean {
  if (string-length ($s) = 0) then
    exit with false ()
  else block {
    zorba:print (("Result: ", eval { $s }, $nl));
    exit with true();
  };
};

while (local:calc-one (zorba:read-line ()))
{ (); }

error: pathspec 'test/parser/Queries/scripting1.xq' did not match any file(s) known to git


Added updating functions for term fields.

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


Add BaseX Inspect Module function signatures.

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

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

declare namespace xqdoc = "http://www.xqdoc.org/1.0";

declare %a:since("basex", "7.7") function inspect:functions() as function(*)* external;
declare %a:since("basex", "7.7") function inspect:functions($uri as xs:string) as function(*)* external;
declare %a:since("basex", "8.5") function inspect:function-annotations($function as function(*)?) as map(xs:QName, xs:anyAtomicType*) external;
declare %a:since("basex", "8.5") function inspect:static-context($function as function(*)?, $name as xs:string) as item()* external;
declare %a:since("basex", "7.7") function inspect:function($function as function(*)) as element(function) external;
declare %a:since("basex", "7.7") function inspect:context() as element(context) external;
declare %a:since("basex", "7.7") function inspect:module($uri as xs:string) as element(module) external;
declare %a:since("basex", "7.7") function inspect:xqdoc($uri as xs:string) as element(xqdoc:xqdoc) external;

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


Add BaseX Validate Module function signatures.

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

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

declare %a:since("basex", "7.3") function validate:dtd($input as item()) as empty-sequence() external;
declare %a:since("basex", "7.3") function validate:dtd($input as item(), $schema as xs:string?) as empty-sequence() external;
declare %a:since("basex", "7.6") function validate:dtd-info($input as item()) as xs:string* external;
declare %a:since("basex", "7.6") function validate:dtd-info($input as item(), $schema as xs:string?) as xs:string* external;
declare %a:since("basex", "8.3") function validate:dtd-report($input as item()) as element(report) external;
declare %a:since("basex", "8.3") function validate:dtd-report($input as item(), $schema as xs:string?) as element(report) external;
declare %a:since("basex", "7.3") function validate:xsd($input as item()) as empty-sequence() external;
declare %a:since("basex", "7.3") function validate:xsd($input as item(), $schema as item()?) as empty-sequence() external;
declare %a:since("basex", "7.3") function validate:xsd($input as item(), $schema as item()?, $version as xs:string) as empty-sequence() external;
declare %a:since("basex", "7.6") function validate:xsd-info($input as item()) as xs:string* external;
declare %a:since("basex", "7.6") function validate:xsd-info($input as item(), $schema as item()?) as xs:string* external;
declare %a:since("basex", "7.6") function validate:xsd-info($input as item(), $schema as item()?, $version as xs:string) as xs:string* external;
declare %a:since("basex", "8.3") function validate:xsd-report($input as item()) as element(report) external;
declare %a:since("basex", "8.3") function validate:xsd-report($input as item(), $schema as xs:string?) as element(report) external;
declare %a:since("basex", "8.3") function validate:xsd-report($input as item(), $schema as xs:string?, $version as xs:string) as element(report) external;
declare %a:since("basex", "8.3") function validate:rng($input as item(), $schema as item()) as empty-sequence() external;
declare %a:since("basex", "8.3") function validate:rng($input as item(), $schema as item(), $compact as xs:boolean) as empty-sequence() external;
declare %a:since("basex", "8.3") function validate:rng-info($input as item(), $schema as item()) as xs:string* external;
declare %a:since("basex", "8.3") function validate:rng-info($input as item(), $schema as item(), $compact as xs:boolean) as xs:string* external;
declare %a:since("basex", "8.3") function validate:rng-report($input as item(), $schema as xs:string) as element(report) external;
declare %a:since("basex", "8.3") function validate:rng-report($input as item(), $schema as xs:string, $compact as xs:boolean) as element(report) external;

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


Begin BaseX Database Module function signatures.

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

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

declare %a:since("basex", "7.0") function db:system() as element(system) external;
declare %a:since("basex", "7.0") function db:option($name as xs:string) as xs:string external;
declare %a:since("basex", "7.0") function db:info($db as xs:string) as element(database) external;
declare %a:since("basex", "7.0") function db:property($db as xs:string, $name as xs:string) as xs:anyAtomicType external;

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


adding files

adding files

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


[test] Tests for numeric comparison of long xs:integer

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


Sort terms alphabetically in ascending order.

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/'


Compare IDs, not term strings.

Compare IDs, not term strings.


Add BaseX Update Module function signatures.

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

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 update:apply($function as function(*), $arguments as array(*)) as empty-sequence() external;
declare %a:since("basex", "9.0") function update:for-each($seq as item()*, $function as function(item()) as item()*) as empty-sequence() external;
declare %a:since("basex", "9.0") function update:for-each-pair($seq1 as item()*, $function as function(item()) as item()*) as empty-sequence() external;
declare %a:since("basex", "9.0") function update:map-for-each($map as map(*), $function as function(xs:anyAtomicType, item()*) as item()*) as item()* external;
declare %a:since("basex", "9.0") function update:output($result as item()*) as empty-sequence() external;
declare %a:since("basex", "9.0") function update:cache() as item()* external;

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


added adapter interface for stored functions

module namespace page = 'http://basex.org/modules/web-page';

import module namespace csr_proc = "https://github.com/his-interop/openinfoman/csr_proc";
(:import module namespace csr_adpt = "https://github.com/his-interop/openinfoman/csr_adpt"; :)
import module namespace csd_webconf =  "https://github.com/his-interop/openinfoman/csd_webconf";
declare namespace csd = "urn:ihe:iti:csd:2013";

declare
  %rest:path("/CSD/adapter")
  %rest:GET
  %output:method("xhtml")
  function page:show_types()
{
  let $funcs := (csr_proc:stored_functions($csd_webconf:db), csr_proc:stored_updating_functions($csd_webconf:db))
  let $searches :=

      {
	for $adapter_func in $funcs[./csd:extension[@urn='urn:openhie.org:openinfoman:csr_adapter']]
        let $desc := $adapter_func/csd:description
        let $type := string($adapter_func/csd:extension[@urn='urn:openhie.org:openinfoman:csr_adapter']/@type)
	let $uuid := string($adapter_func/@uuid)
	return

	   Type ({$type})
	   Adapter ID ({$uuid})

{$desc}

	   {$uuid}

      }

  return page:wrapper($searches)
};

declare
  %rest:path("/CSD/adapter/{$type}")
  %rest:GET
  %output:method("xhtml")
  function page:show_type($type)
{
  let $funcs := (csr_proc:stored_functions($csd_webconf:db), csr_proc:stored_updating_functions($csd_webconf:db))
  let $searches :=

{$type}

        {
	    for $adapter_func in $funcs/csd:extension[@urn='urn:openhie.org:openinfoman:csr_adapter' and @type = $type ]
            let $desc := $adapter_func/csd:description
            let $type := $adapter_func/csd:extension/@type
	    let $uuid := string($adapter_func/@uuid)
	    return

	      Type ({$type})
	      Adapter ID ({$uuid})

{$desc}

	      {$uuid}

	}

  return page:wrapper($searches)
};

declare function page:wrapper($response) {

    <link href="{$csd_webconf:baseurl}static/bootstrap/css/bootstrap.css" rel="stylesheet"/>
    <link href="{$csd_webconf:baseurl}static/bootstrap/css/bootstrap-theme.css" rel="stylesheet"/>

    <link rel="stylesheet" type="text/css" media="screen"   href="{$csd_webconf:baseurl}static/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"/>

error: pathspec 'webapp/adapter.xqm' did not match any file(s) known to git


added view-play module

added view-play module

xquery version "3.0";

module namespace play="http://xqueryinstitute.org/play";

(:
 : Retrieve play xml transform with xsl for html output
 : For local installations you can not use the html APIs, must use the text API
 : text API seems to have a character limitation.
:)

import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace config="http://localhost:8080/exist/apps/xq-institute/config" at "config.xqm";
import module namespace alchemy="http://xqueryinstitute.org/alchemy" at "alchemy.xqm" ;

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

(:~
 : Runs play through xslt transformation
 : @param $uri passes internal uri for play
:)
declare function play:view-play-html($rec as node()){
    transform:transform($rec, doc('../resources/xsl/teiHTML.xsl'),() )
};

(:~
 : Retrieve play xml transform with xsl for html output
 : @param $uri passes internal uri for play
:)
declare %templates:wrap function play:get-play($node as node(), $model as map(*)) as node(){
    let $uri := request:get-parameter('uri', '')
    let $displayURI := replace($uri,'/indexed-plays','/plays')
    let $rec := xmldb:document($uri)/tei:TEI
    return

                {play:view-play-html($rec)}

,

Text analysis by AlchemyAPI:

                    {alchemy:get-tone($rec)}

};

error: pathspec 'modules/view-play.xqm' did not match any file(s) known to git


We are not joining strings but anchor elements.


Create sample-query.xqy

Create sample-query.xqy

import module namespace transitive = "http://marklogic.com/transitive" at "/main/app/lib/transitive-library.xqy";

declare option xdmp:mapping "false";

let $skos-ns := "http://www.w3.org/2004/02/skos/core#"
let $options := map:entry("axis","descendant")
return
transitive:traverser(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),(),$options)

error: pathspec 'transitive/sample-query.xqy' did not match any file(s) known to git


company2 xquery transformation

company2 xquery transformation

declare function local:transform($nodefilter as function(element()) as xs:boolean, $nodeadd as function(element()) as item()*, $attrfilter as function(element(), attribute()) as attribute()*, $attradd as function(element()) as attribute()*, $input as item()*) as item()* {
for $node in $input
   return
      typeswitch($node)
        case element()
         return
          if ($nodefilter($node)) then
              element {name($node)} {
                $nodeadd($node),
                $attradd($node),
                for $att in $node/@*
                    return $attrfilter($node, $att)
                ,
                for $child in $node
                   return local:transform($nodefilter, $nodeadd, $attrfilter, $attradd, $child/node())

              }
          else ()
        default return $node
};

let $nf1 := function($node as element()) as xs:boolean {xs:boolean('true')},
	$na1 := function($node as element()) as item()* {if (name($node) = 'dep_name') then
                    for $na in distinct-values($node/../constitution/@cno) return element {'newET0'} {
                    attribute {'cno'} {$na},
                    for $nu in distinct-values($node/../constitution/employee[$node/../constitution/@cno = $na]/@eno) return
                  element {'newET00'} {attribute {'eno'} {$nu}},
                  for $nu in distinct-values($node/../constitution/employee[$node/../constitution/@cno = $na]/@age) return
                 element {'newET01'} {attribute {'age'} {$nu}}
                 }
                else ()},
  $af1 := function($node as element(), $att as attribute()) as attribute()* {
    if (name($node) != 'constitution' or name($att) != 'cno' ) then
      attribute {name($att)} {$att}
    else ()},
  $aa1 := function($node as element()) as attribute()* { () }
  return
	local:transform($nf1, $na1, $af1, $aa1, doc("test.xml")/company)

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


Added xq-promise.xqm interop XQuery module

fatal: unable to access 'https://github.com/james-jw/xq-promise.git/': The requested URL returned error: 403


Added listener startup script

Added listener startup script

xquery version "3.1";

(:~
: Simple script to start the replication listener
:)

import module namespace replication="http://exist-db.org/xquery/replication" at "java:org.exist.jms.xquery.ReplicationModule";

let $jmsConfiguration := map {
        "java.naming.factory.initial" := "org.apache.activemq.jndi.ActiveMQInitialContextFactory",
        "java.naming.provider.url" := "tcp://localhost:61616",
        "connection-factory" := "ConnectionFactory",
        "destination" := "dynamicTopics/eXistdb-replication-example",
        "subscriber.name" := "SubscriptionId",
        "connection.client-id" := "ClientId"
    }

return
    replication:register($jmsConfiguration)

error: pathspec 'web/demo/replication/startListener.xq' did not match any file(s) known to git


add auth.xqm

add auth.xqm

fatal: unable to access 'https://github.com/grantmacken/markup.co.nz.git/': The requested URL returned error: 403


[test] add tests for except operator

[test] add tests for except operator

see #1348

xquery version "3.0";

module namespace excepttest="http://exist-db.org/xquery/test/except";
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
declare namespace tei="http://www.tei-c.org/ns/1.0";

declare variable $excepttest:DATA :=
    <TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="sha-mac">
        <text>

                    Act 1

        </text>
    </TEI>;

declare variable $excepttest:DATA2 :=
    <TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="sha-mac">
        <text>

                    Act 12

        </text>
    </TEI>;

declare variable $excepttest:COLLECTION_NAME := "/exceptTest";
declare variable $excepttest:SUBCOL1_NAME := $excepttest:COLLECTION_NAME||"/col1";
declare variable $excepttest:SUBCOL2_NAME := $excepttest:COLLECTION_NAME||"/col2";

declare variable $excepttest:COLLECTION := collection("/db"||$excepttest:COLLECTION_NAME);
declare variable $excepttest:SUBCOL1 := collection("/db"||$excepttest:SUBCOL1_NAME);
declare variable $excepttest:SUBCOL2 := collection("/db"||$excepttest:SUBCOL2_NAME);

declare
%test:setUp
function excepttest:setup() {

    xmldb:create-collection("/db", $excepttest:COLLECTION_NAME),
    xmldb:create-collection("/db", $excepttest:SUBCOL1_NAME),
    xmldb:create-collection("/db", $excepttest:SUBCOL2_NAME),
    xmldb:store("/db"||$excepttest:SUBCOL1_NAME, "test.xml", $excepttest:DATA),
    xmldb:store("/db"||$excepttest:SUBCOL2_NAME, "test2.xml", $excepttest:DATA2)
};

declare
 %test:tearDown
 function excepttest:cleanup() {
 xmldb:remove($excepttest:COLLECTION_NAME)
 };

declare
%test:assertEquals("Act 1")
function excepttest:except-wildcard() {
 ($excepttest:COLLECTION/* except $excepttest:SUBCOL2/*)//tei:head/text()
};

declare
%test:assertEquals("Act 1")
function excepttest:except-node-name() {
 ($excepttest:COLLECTION/tei:TEI except $excepttest:SUBCOL2/tei:TEI)//tei:head/text()
};

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


xenaQuery to find genes within a genomic coordinates

; refGeneRange
(fn [dataset chr start end]
	(xena-query {:select ["position (2)" "position" "exonCount" "exonStarts" "exonEnds" "name2"]
				:from [dataset]
				:where [:in "position" [[chr start end]]]}))

error: pathspec 'js/queries/refGeneRange.xq' did not match any file(s) known to git


Added further XQuery 3.0 String Conatentaion Expression tests

fatal: remote error: upload-pack: not our ref 81908871173e8ea0705174e07fb0fb453837b65f
fatal: the remote end hung up unexpectedly


Added a new folder called 'tools' that will hold different useful queries.

(: this query loads a rezults.xml file and reports the number of 'non applicable' tests grouped by feature :)
(:
  sample usage
  ./zorba -f -q ../../test/fots_driver/tools/dependencies.xq
          -e pathFailures:=results_12_nov.xml
          -o driver_dependencies.xml
          --indent
:)

  import module namespace file = "http://expath.org/ns/file";

  declare default element namespace "http://www.w3.org/2010/09/qt-fots-catalog";
  declare namespace fots = "http://www.w3.org/2010/09/qt-fots-catalog";

  declare variable $pathFailures external;

  variable $failures := fn:parse-xml(file:read-text($pathFailures));

  <report> {
    for $d in distinct-values(data($failures/fots:test-cases/fots:test-set/fots:test-case[@result="not applicable"]/@comment))
    order by $d
    return
      <dependency type="{$d}"> {
        <value number-of-tests="{count($failures/fots:test-cases//fots:test-set//fots:test-case[@result="not applicable" and @comment=$d])}" />
      }</dependency>
 }</report>

error: pathspec 'test/fots_driver/tools/dependencies.xq' did not match any file(s) known to git


retrieve idnos via ddb

retrieve idnos via ddb

declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace hgv = "HGV";
declare option saxon:output "method=xml";
declare option saxon:output "indent=yes";
declare variable $idpData external;

(: java -Xms512m -Xmx1536m net.sf.saxon.Query -q:idno_via_ddb.xql idpData=.../idp.data > idno_via_ddb.xml :)

<list>{
  for $doc in collection(concat($idpData, '/DDB_EpiDoc_XML?select=*.xml;recurse=yes'))

    let $hgv := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type='HGV']
    let $tm  := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type='TM']
    let $ddb := $doc/tei:TEI/tei:teiHeader/tei:fileDesc/tei:publicationStmt/tei:idno[@type='ddb-hybrid']

    return <item><idno type="hgv">{data($hgv)}</idno><idno type="tm">{data($tm)}</idno><idno type="ddb">{data($ddb)}</idno></item>

}</list>

error: pathspec 'src/Papyrillio/BeehiveBundle/Resources/data/idno_via_ddb.xql' did not match any file(s) known to git


s/unreviewed/is_unreviewed/ for consistency.


new xquery report to generate a CSV file with information about digitized files listed in unittitles [#46492989]

(:
XQuery to get a list of all text notes about digitized files
in the text of the unittitle.  Searches for unittitles that contain the string "digitized",
and then splits out the portion in brackets, e.g. [digitized; filename 1234].

Generates a comma-separate list of:
  digitized note
  entire unittitle that conained the digitized note
  filename
  manuscript id (from archdesc/unitid identifier attribute)
  box
  folder
:)

declare namespace e='urn:isbn:1-931666-22-9';
declare namespace util='http://exist-db.org/xquery/util';

for $title in //e:unittitle[contains(., 'digitized')]
(: many unittitles contain multiple bracketed comments; restrict to digitized to grab correct one :)
let $digitized := concat('digitized', substring-before(substring-after($title, '[digitized'), ']'))
let $docname := util:document-name($title)
let $mss := $title/ancestor::e:ead//e:unitid/@identifier
let $box := $title/preceding-sibling::e:container[@type="box"]
let $folder := $title/preceding-sibling::e:container[@type="folder"]
(: return quoted, comma-delimited since unittitles may contain commas :)
return concat('"', normalize-space($digitized), '",',
    '"', normalize-space($title), '",',
    '"', normalize-space($docname), '",',
    '"', normalize-space($mss), '",',
    '"', normalize-space($box), '",',
    '"', normalize-space($folder), '",'
    )

error: pathspec 'xquery-reports/digitized-files.xquery' did not match any file(s) known to git


new reference test

new reference test

import module namespace
coll="http://www.zorba-xquery.com/zorba/collection-functions";

import module namespace zorba =
"http://www.zorba-xquery.com/zorba/node-ref-functions";

declare sequential function local:test()
{
coll:create-collection("a");
coll:insert-nodes-last("a", <c d="e"></c>);

exit with
fn:data(zorba:node-by-reference(zorba:node-reference(fn:collection("a")/b/c/@d)));
};

local:test()

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


Attempt to access the HTML tidy functionality built-in to Zorba

import module namespace html = "http://www.zorba-xquery.com/modules/converters/html";

(:
html:parse("file:///home/cefn/Documents/highwire/participatory%20firmware%20design/readinglog/notes/ff6c0ab588ef886f7e1b65d9e36e480d.html")
:)
html:parse("
Hello
")

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


Add missing query file for matrix chrom view.

; datasetChromProbeValues
(fn [dataset samples chr start end]
	(let [probemap (:probemap (car (query {:select [:probemap]
										   :from [:dataset]
										   :where [:= :name dataset]})))
			position (xena-query {:select ["name" "position"] :from [probemap] :where [:in "position" [[chr start end]]]})
			probes (position "name")]
	  [position
		(fetch [{:table dataset
				 :samples samples
				 :columns probes}])]))

error: pathspec 'js/queries/datasetChromProbeValues.xq' did not match any file(s) known to git


Experiments

Experiments

let $m := { "id" : "0"}
return

{
        {
             for $n in (1 to 1)
             return a
        }
}

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


added utility script to create SVS and CSD files from bong county excel spreadsheet

import module namespace  zip = "http://expath.org/ns/zip";
import module namespace functx = "http://www.functx.com";

declare namespace csd = "urn:ihe:iti:csd:2013";

(: docProps/core.xml namespaces :)
declare namespace cprop = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ;
declare namespace dc = "http://purl.org/dc/elements/1.1/";
declare namespace dcterms = "http://purl.org/dc/terms/";
declare namespace dcmitype = "http://purl.org/dc/dcmitype/" ;

(:docProps/app.xml namesspaces :)
declare namespace prop = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";
declare namespace vect = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";

(:xl/worksheets/sheet*.xml namespaces :)
declare namespace sheet = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
declare namespace rel = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
declare namespace markup = "http://schemas.openxmlformats.org/markup-compatibility/2006";
declare namespace x14ac = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac";

let $file := "Bong.xlsx"
let $base-urn  := concat("urn:x-excelfile:" , $file ,":gCHV")
let $gchv-type-code-scheme := "2.25.17301777793732765478144807142873029913013910280806"

let $normalize-name := function ($name) {
  replace(lower-case(string($name)),"[^a-z]","")
}

let $dhis_doc := doc("dhis2_training_liberia_as_CSD.xml") (:could also be something pointing at an SVS file or the DB :)

let $facs :=
  for $fac in $dhis_doc/csd:CSD/csd:facilityDirectory/csd:facility
  return <facility urn="{$fac/@urn}" name="{$normalize-name($fac/csd:primaryName/text())}"/>

let $orgs :=
  for $org in $dhis_doc/csd:CSD/csd:organizationDirectory/csd:organization
  return <organization urn="{$org/@urn}" name="{$normalize-name($org/csd:primaryName/text())}"/>

let $lookup-facility-id := function($name) {
  let $n-name := $normalize-name($name)
  let $fac := ($facs[@name = $n-name])[1]
  return
    if (exists($fac))
    then string($fac/@urn)
    else concat($base-urn, ":facility:",$n-name)
}

let $lookup-organization-id := function($name) {
  let $n-name := $normalize-name($name)
  let $org := ($orgs[@name = $n-name])[1]
  return
    if (exists($org))
    then string($org/@urn)
    else concat($base-urn, ":organization:" ,  ':' , $n-name)
}

let $sheet-list := zip:xml-entry($file,"docProps/app.xml")/prop:Properties/prop:TitlesOfParts/vect:vector/vect:lpstr
let $contact-sheet-pos := functx:index-of-node($sheet-list,$sheet-list[./text() = "Contacts"])
let $contact-sheet-file := concat("xl/worksheets/sheet", $contact-sheet-pos , '.xml')
let $modified := substring-before(string(zip:xml-entry($file,"docProps/core.xml")/cprop:coreProperties/dcterms:modified),'Z')
let $shared-strings := zip:xml-entry($file,"xl/sharedStrings.xml")

let $lookup-ref := function($ref) {
  let $lookup := $shared-strings/sheet:sst/sheet:si[position() = ($ref + 1)]/sheet:t
  return
     if (exists($lookup))
     then  $lookup/text()
     else concat('#',$ref)
}

let $get-cell-value := function($cell) {
  let $text := $cell/sheet:v/text()
  return
    if ($cell/@t = "s")
    then $lookup-ref($text)
    else $text
}

let $contacts :=
  for $contact in zip:xml-entry($file,$contact-sheet-file)/sheet:worksheet/sheet:sheetData/sheet:row[position() > 1]
  let $row := string($contact/@r)
  let $id := $get-cell-value($contact/sheet:c[@r = concat("A",$row)])
  let $cty := $get-cell-value($contact/sheet:c[@r = concat("B",$row)])
  let $dis := $get-cell-value($contact/sheet:c[@r = concat("C",$row)])
  let $fac := $get-cell-value($contact/sheet:c[@r = concat("D",$row)])
  let $name := $get-cell-value($contact/sheet:c[@r = concat("E",$row)])
  let $pos := $get-cell-value($contact/sheet:c[@r = concat("F",$row)])
  let $cell := $get-cell-value($contact/sheet:c[@r = concat("G",$row)])
  let $urn := concat($base-urn,":provider:",$id)
  let $ghcv-type := $normalize-name($pos)

  return
    <csd:provider urn="{$urn}" >
      <csd:codedType code="{$ghcv-type}" codingScheme="{$gchv-type-code-scheme}" />
      <csd:demographic>
	<csd:name>
	  <csd:commonName>{$name}</csd:commonName>
	</csd:name>
	{
	  if (not (functx:all-whitespace($cell)))
	  then
	    <csd:contactPoint>
              <csd:codedType code="BP" codingScheme="urn:ihe:iti:csd:2013:contactPoint">{$cell}</csd:codedType>
	    </csd:contactPoint>
          else ()
	}
	{
	  let $orglist :=
	    (
	      if (not(functx:all-whitespace($cty))) then $cty else (),
	      if (not(functx:all-whitespace($dis))) then $dis else ()
	    )
	  return
	    if (count($orglist) > 0)
	    then
	      <csd:organizations>
		{
		  for $org in $orglist
		  return <csd:organization urn="{$lookup-organization-id($org)}"></csd:organization>
		}
	      </csd:organizations>
	    else ()
	}
	{
	  if (not (functx:all-whitespace($fac)))
	  then <csd:facilities><csd:facility urn="{$lookup-facility-id($fac)}"/></csd:facilities>
	  else  ()
	}

	<csd:record created="{$modified}" updated="{$modified}" status="106-001" sourceDirectory="file://{$file}"/>
      </csd:demographic>
    </csd:provider>

let $csd :=
  <csd:CSD>
    <csd:organizationDirectory/>
    <csd:serviceDirectory/>
    <csd:facilityDirectory/>
    <csd:providerDirectory>{$contacts}</csd:providerDirectory>
  </csd:CSD>

let $svs-gchv :=
  <svs:ValueSet xmlns:svs="urn:ihe:iti:svs:2008" id="{$gchv-type-code-scheme}" version="20131201" displayName="gCHV Types">
    <svs:ConceptList xml:lang="en-US">

      {
	let $ghcv-types :=
	  for $contact in zip:xml-entry($file,$contact-sheet-file)/sheet:worksheet/sheet:sheetData/sheet:row[position() > 1]
	    let $row := string($contact/@r)
	    return $get-cell-value($contact/sheet:c[@r = concat("F",$row)])
         return
	   for $ghcv-type in $ghcv-types
	   let $code := $normalize-name( $ghcv-type)
           return <svs:Concept code="{$code}" displayName="gCHV: {$ghcv-type}" codeSystem="{$gchv-type-code-scheme}"/>
       }
    </svs:ConceptList>
  </svs:ValueSet>

return
  (
    file:write(concat($file,'.csd.xml'),$csd)
    ,file:write(concat($file,'.svs.xml'),$svs-gchv)
  )

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


Accidentaly omitted extsimilar from initial commit

xquery version "1.0-ml";

module namespace ext = "http://marklogic.com/rest-api/resource/extsimilar";

declare default function namespace "http://www.w3.org/2005/xpath-functions";

declare namespace roxy = "http://marklogic.com/roxy";

(:
 : To add parameters to the functions, specify them in the params annotations.
 : Example
 :   declare %roxy:params("uri=xs:string", "priority=xs:int") ext:get(...)
 : This means that the get function will take two parameters, a string and an int.
 :)

(:
 :)
declare
%roxy:params("uri=xs:string", "limit=xs:int?")
function ext:get(
  $context as map:map,
  $params  as map:map
) as document-node()*
{
  ext:post($context, $params, ())
};

(:
 :)
declare
%roxy:params("uri=xs:string", "limit=xs:int?")
function ext:post(
  $context as map:map,
  $params  as map:map,
  $input   as document-node()*
) as document-node()*
{
  let $output-types := map:put($context, "output-types", "application/json")
  let $uri := map:get($params, "uri")
  let $limit := xs:int((map:get($params, "limit"), '5')[1])
  let $collections := xdmp:document-get-collections($uri)
  let $collection-q := if (fn:exists($collections)) then cts:collection-query($collections) else ()
  let $content :=
    if (exists($uri)) then
      json:to-array(
        (
          for $doc in cts:search(collection(), cts:and-query(($collection-q,cts:similar-query(doc($uri)))))
          let $similar-uri := base-uri($doc)
          where $similar-uri != $uri
          return $similar-uri
        )[1 to $limit]
      )
    else json:array()
  let $response := json:object()
  let $_ := map:put($response, "similar", $content)
  return (xdmp:set-response-code(200, "OK"), document { xdmp:to-json($response) })
};

error: pathspec 'rest-api/ext/extsimilar.xqy' did not match any file(s) known to git


Navigation by headers.

Navigation by headers.

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

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

let $headerstrings := $logx:collection//h2/string()
return
logx:webpage(
    for $item in distinct-values($headerstrings)
        let $count := count($headerstrings[.=$item])
        order by $count descending
        return
{($count, logx:viewer-link(string-join(('xq/entries.xq',concat('header=', $item)), '&'), $item), ' ')}

    (:
        return {$item}
    :)
)

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


Remove unnecessary line.

Remove unnecessary line.

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/'


Create  A Test dataset in qconsole

Create  A Test dataset in qconsole

xdmp:document-insert(
"/mergers/bofa.xml",
<triples>{
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/merryl-lynch")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/ustrust")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/countrywide-financial")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/mbna")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/continental-bank")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/bankamerica")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/security-pacific-bancorp")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/nations-bank")),
  sem:triple(sem:iri("http://company/bofa"),sem:iri("http://rel#acquired"),sem:iri("http://company/fleet-boston")),

  sem:triple(sem:iri("http://company/fleet-boston"),sem:iri("http://rel#acquired"),sem:iri("http://company/summit-bancorp")),
  sem:triple(sem:iri("http://company/fleet-boston"),sem:iri("http://rel#acquired"),sem:iri("http://company/bank-boston")),
  sem:triple(sem:iri("http://company/fleet-boston"),sem:iri("http://rel#acquired"),sem:iri("http://company/fleet-financial")),

  sem:triple(sem:iri("http://company/bank-boston"),sem:iri("http://rel#acquired"),sem:iri("http://company/bancboston-holdings")),
  sem:triple(sem:iri("http://company/bank-boston"),sem:iri("http://rel#acquired"),sem:iri("http://company/baybanks")),

  sem:triple(sem:iri("http://company/summit-bancorp"),sem:iri("http://rel#acquired"),sem:iri("http://company/ujb-financial"))
}</triples>);

error: pathspec 'transitive/test-load-triples.xqy' did not match any file(s) known to git


Detect self-servicing contracting authorities

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

for $public-contract in /PrehledZakazekZVestnikuVZ/VerejnaZakazka[ZadavatelICO = DodavatelICO]
  return ($public-contract/CisloFormulareNaVVZ, '
')

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


add test case

add test case

SVN-Revision: 3365

declare default element namespace "urn:hl7-org:v2xml";
declare variable $docName as xs:string external;
document
{
   element ClinicalDocument
   {
      attribute classCode{"DOCCLIN"},
      attribute moodCode{"EVN"},
      element typeId
      {
         attribute root{"2.16.840.1.113883.1.3"},
         attribute extension{string("A123")},
         ""
      },
      element id
      {
         attribute extension{data(doc($docName)/ADT_A03/MSH/MSH.10)},
         ""
      },
      element code
      {
         attribute code{data(doc($docName)/ADT_A03/MSH/MSH.11/PT.1)},
         ""
      },
      element title
      {
         attribute representation{"TXT"},
         attribute mediaType{"text/plain"},
         string("Discharge Sumary")
      },
      element effectiveTime
      {
         attribute value{data(doc($docName)/ADT_A03/MSH/MSH.7/TS.1)},
         ""
      },
      element confidentialityCode
      {
         attribute code{data(doc($docName)/ADT_A03/MSH/MSH.11/PT.2)},
         ""
      },
      element languageCode
      {
         attribute code{data(doc($docName)/ADT_A03/MSH/MSH.19/CE.2)},
         ""
      },
      element recordTarget
      {
         attribute typeCode{"RCT"},
         attribute contextControlCode{"OP"},
         element patientRole
         {
            attribute classCode{"PAT"},
            element id
            {
               attribute extension{data(doc($docName)/ADT_A03/PID/PID.19)},
               attribute assigningAuthorityName{data(doc($docName)/ADT_A03/PID/PID.19/@LongName)},
               ""
            },
            element addr
            {
               for $item_temp1 in doc($docName)/ADT_A03/PID/PID.11/XAD.1/SAD.1 return
               element state
               {
                  attribute partType{"STA"},
                  attribute representation{"TXT"},
                  attribute mediaType{"text/plain"},
                  $item_temp1/text()
               },
               ""
            },
            element telecom
            {
               attribute use{string("H")},
               attribute value{concat(string("tel:"),doc($docName)/ADT_A03/PID/PID.13/XTN.1)},
               ""
            },
            for $item_temp1 in doc($docName)/ADT_A03/PID return
            element patient
            {
               attribute classCode{"PSN"},
               attribute determinerCode{"INSTANCE"},
               element typeId
               {
                  attribute root{"2.16.840.1.113883.1.3"},
                  attribute extension{data($item_temp1/PID.1)},
                  ""
               },
               element id
               {
                  attribute extension{data($item_temp1/PID.3/CX.1)},
                  ""
               },
               element name
               {
                  attribute use{string("L")},
                  for $item_temp2 in $item_temp1/PID.5/XPN.1/FN.1 return
                  element family
                  {
                     attribute partType{"FAM"},
                     attribute representation{"TXT"},
                     attribute mediaType{"text/plain"},
                     $item_temp2/text()
                  },
                  for $item_temp2 in $item_temp1/PID.5/XPN.2 return
                  element given
                  {
                     attribute partType{"GIV"},
                     attribute representation{"TXT"},
                     attribute mediaType{"text/plain"},
                     $item_temp2/text()
                  },
                  ""
               },
               element administrativeGenderCode
               {
                  attribute code{data($item_temp1/PID.8)},
                  ""
               },
               element birthTime
               {
                  attribute value{data($item_temp1/PID.7/TS.1)},
                  ""
               },
               element maritalStatusCode
               {
                  attribute code{data($item_temp1/PID.16/CE.1)},
                  attribute codeSystem{data($item_temp1/PID.16/CE.3)},
                  attribute displayName{data($item_temp1/PID.16/CE.2)},
                  ""
               },
               element religiousAffiliationCode
               {
                  attribute code{data($item_temp1/PID.17/CE.1)},
                  attribute codeSystem{data($item_temp1/PID.17/CE.3)},
                  attribute displayName{data($item_temp1/PID.17/CE.2)},
                  ""
               },
               $item_temp1/text()
            },
            ""
         },
         ""
      },
      element author
      {
         attribute typeCode{"AUT"},
         attribute contextControlCode{"OP"},
         element time
         {
            attribute value{data(doc($docName)/ADT_A03/MSH/MSH.7/TS.1)},
            ""
         },
         element assignedAuthor
         {
            attribute classCode{"ASSIGNED"},
            element id
            {
               attribute extension{data(doc($docName)/ADT_A03/MSH/MSH.4/HD.1)},
               attribute assigningAuthorityName{data(doc($docName)/ADT_A03/MSH/MSH.4/HD.2)},
               ""
            },
            ""
         },
         ""
      },
      element componentOf
      {
         attribute typeCode{"COMP"},
         for $item_temp1 in doc($docName)/ADT_A03/PV1 return
         element encompassingEncounter
         {
            attribute classCode{"ENC"},
            attribute moodCode{"EVN"},
            element id
            {
               attribute extension{data($item_temp1/PV1.1)},
               ""
            },
            element code
            {
               attribute code{data($item_temp1/PV1.2)},
               ""
            },
            element effectiveTime
            {
               attribute operator{"I"},
               attribute value{data($item_temp1/PV1.44/TS.1)},
               ""
            },
            element dischargeDispositionCode
            {
               attribute code{data($item_temp1/PV1.36)},
               ""
            },
            element responsibleParty
            {
               attribute typeCode{"RESP"},
               element assignedEntity
               {
                  attribute classCode{"ASSIGNED"},
                  element id
                  {
                     attribute extension{data($item_temp1/PV1.7/XCN.1)},
                     attribute assigningAuthorityName{data($item_temp1/PV1.7/XCN.14/HD.2)},
                     ""
                  },
                  element code
                  {
                     attribute code{data($item_temp1/PV1.10)},
                     ""
                  },
                  element assignedPerson
                  {
                     attribute classCode{"PSN"},
                     attribute determinerCode{"INSTANCE"},
                     element name
                     {
                        for $item_temp2 in $item_temp1/PV1.7/XCN.2/FN.1 return
                        element family
                        {
                           attribute partType{"FAM"},
                           attribute representation{"TXT"},
                           attribute mediaType{"text/plain"},
                           $item_temp2/text()
                        },
                        ""
                     },
                     ""
                  },
                  ""
               },
               ""
            },
            element location
            {
               attribute typeCode{"LOC"},
               element healthCareFacility
               {
                  attribute classCode{"SDLOC"},
                  element id
                  {
                     attribute extension{data($item_temp1/PV1.3/PL.3)},
                     ""
                  },
                  element id
                  {
                     attribute extension{data($item_temp1/PV1.3/PL.2)},
                     ""
                  },
                  element id
                  {
                     attribute extension{data($item_temp1/PV1.3/PL.2)},
                     ""
                  },
                  ""
               },
               ""
            },
            $item_temp1/text()
         },
         ""
      },
      element component
      {
         attribute typeCode{"COMP"},
         attribute contextConductionInd{"true"},
         element typeId
         {
            attribute root{"2.16.840.1.113883.1.3"},
            attribute extension{string("COMP")},
            ""
         },
         element structuredBody
         {
            attribute classCode{"DOCBODY"},
            attribute moodCode{"EVN"},
            element component
            {
               attribute typeCode{"COMP"},
               attribute contextConductionInd{"true"},
               element typeId
               {
                  attribute root{"2.16.840.1.113883.1.3"},
                  attribute extension{string("PRCS")},
                  ""
               },
               element section
               {
                  attribute classCode{"DOCSECT"},
                  attribute moodCode{"EVN"},
                  element title
                  {
                     attribute representation{"TXT"},
                     attribute mediaType{"text/plain"},
                     string("CDA Record")
                  },
                  for $item_temp1 in doc($docName)/ADT_A03/ADT_A03.PROCEDURE/PR1 return
                  element entry
                  {
                     attribute typeCode{"COMP"},
                     attribute contextConductionInd{"true"},
                     element procedure
                     {
                        attribute classCode{string("ACCM")},
                        attribute moodCode{string("APT")},
                        element id
                        {
                           attribute root{string("2.56.34.2345.5434.444")},
                           attribute extension{data($item_temp1/PR1.1)},
                           ""
                        },
                        element code
                        {
                           attribute code{data($item_temp1/PR1.3/CE.1)},
                           attribute codeSystem{data($item_temp1/PR1.3/CE.3)},
                           attribute displayName{data($item_temp1/PR1.3/CE.2)},
                           ""
                        },
                        element effectiveTime
                        {
                           attribute operator{"I"},
                           attribute value{data($item_temp1/PR1.5/TS.1)},
                           ""
                        },
                        ""
                     },
                     $item_temp1/text()
                  },
                  ""
               },
               ""
            },
            element component
            {
               attribute typeCode{"COMP"},
               attribute contextConductionInd{"true"},
               element typeId
               {
                  attribute root{"2.16.840.1.113883.1.3"},
                  attribute extension{string("OBSR")},
                  ""
               },
               element section
               {
                  attribute classCode{"DOCSECT"},
                  attribute moodCode{"EVN"},
                  element title
                  {
                     attribute representation{"TXT"},
                     attribute mediaType{"text/plain"},
                     string("Observation results")
                  },
                  for $item_temp1 in doc($docName)/ADT_A03/OBX return
                  element entry
                  {
                     attribute typeCode{"COMP"},
                     attribute contextConductionInd{"true"},
                     element observation
                     {
                        attribute classCode{string("ALRT")},
                        attribute moodCode{string("DEF")},
                        element id
                        {
                           attribute root{string("2.56.34.2345.5434.555")},
                           attribute extension{data($item_temp1/OBX.1)},
                           ""
                        },
                        element code
                        {
                           attribute code{data($item_temp1/OBX.3/CE.1)},
                           attribute displayName{data($item_temp1/OBX.3/CE.2)},
                           ""
                        },
                        for $item_temp2 in $item_temp1/OBX.4 return
                        element derivationExpr
                        {
                           attribute representation{"TXT"},
                           attribute mediaType{"text/plain"},
                           $item_temp2/text()
                        },
                        for $item_temp2 in $item_temp1/OBX.5 return
                        element text
                        {
                           attribute mediaType{"text/plain"},
                           attribute integrityCheckAlgorithm{"SHA-1"},
                           attribute representation{"TXT"},
                           $item_temp2/text()
                        },
                        element statusCode
                        {
                           attribute code{string("completed")},
                           ""
                        },
                        element effectiveTime
                        {
                           attribute operator{"I"},
                           attribute value{data($item_temp1/OBX.14/TS.1)},
                           ""
                        },
                        ""
                     },
                     $item_temp1/text()
                  },
                  ""
               },
               ""
            },
            ""
         },
         ""
      },
      ""
   }

}

error: pathspec 'software/cmts/workingspace/cda/cda_transform_xql.xq' did not match any file(s) known to git


[testsuite] Tests for xmldb:copy-resource and xmldb:copy-collection

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


Fixed a non ascii character.

Fixed a non ascii character.

(: XQuery Join Aggregate Query :)
(: Find the lowest recorded temperature (TMIN) in the state of Oregon for     :)
(: 2001.                                                                      :)
fn:min(
    let $collection1 := "/tmp/1.0_partition_ghcnd_all_xml/stations"
    for $s in collection($collection1)/stationCollection/station

    let $collection2 := "/tmp/1.0_partition_ghcnd_all_xml/sensors"
    for $r in collection($collection2)/dataCollection/data

    let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
    where $s/id eq $r/station
        and (some $x in $s/locationLabels satisfies ($x/type eq "ST" and $x/displayName eq "Oregon"))
        and $r/dataType eq "TMIN"
        and fn:year-from-date($date) eq 2001
    return $r/value
) div 10

(: XQuery Join Aggregate Query :)
(: Find the lowest recorded temperature (TMIN) in the state of Oregon for     :)
(: 2001.                                                                      :)
fn:min(
    let $collection1 := "/tmp/1.0_partition_ghcnd_all_xml/stations"
    for $s in collection($collection1)/stationCollection/station

    let $collection2 := "/tmp/1.0_partition_ghcnd_all_xml/sensors"
    for $r in collection($collection2)/dataCollection/data

    let $date := xs:date(fn:substring(xs:string(fn:data($r/date)), 0, 11))
    where $s/id eq $r/station
        and (some $x in $s/locationLabels satisfies ($x/type eq "ST" and $x/displayName eq "Oregon”))
        and $r/dataType eq "TMIN"
        and fn:year-from-date($date) eq 2001
    return $r/value
) div 10


added new path test

added new path test

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


New script to find OpenAthens entities that exist in the UK Federation metadata but not in the Eduserv metadata.

xquery version "1.0";
declare default element namespace "urn:oasis:names:tc:SAML:2.0:metadata";
(:This xquery script finds all Eduserv entities that appear in UK Federation metadata
 :but not in the Eduserv metadata.
 :It returns the UK Federation ID and the entityID
 :
 :To run this, you can use the xquery debug perspective in Eclipse, or in Oxygen.
 :You could also download the free version of Saxon from http://saxon.sourceforge.net/
 :and include saxon8.jar in your classpath and then run
 :
 :java net.sf.saxon.query find_OpenAthens_entities_not_in_Eduserv_metadata.xq
 :
 :The output is an XML file listing the entityID's of Eduserv entities that appear in
 :UK Federation metadata but not in the Eduserv metadata.
 :
 :Gary Gray
 :13 July 2010
 :)
 <Entities>
 {
for $f in doc("http://metadata.ukfederation.org.uk/ukfederation-metadata.xml")/EntitiesDescriptor/EntityDescriptor[Organization/OrganizationName='Eduserv']
where $f/@entityID[not(. = /doc("https://auth.athensams.net/saml/metadata?name=ukfederation")/EntitiesDescriptor/EntityDescriptor/@entityID)]
return
<Entity ID="{data($f/@ID)}">{data($f/@entityID)}
</Entity>
}
</Entities>

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


First cut additions to the mail extension module.
New functions have been added to access mailboxes and to be able to get a list of messages in a mailbox, which is sufficient to easily generate RSS/ATOM feeds for new mail in your inbox.

All of these new functions are based on the JavaMail API, and so the mail.jar file has been added to lib/user (1.4.2 which is the latest version hot off the press).

The old  send-email function has been deprecated, but is still in place. It will be replaced with a new send() function that uses JavaMail API calls rather than directly  talking to an SMTP server.

More functions to allow manipulation of folders/messages/attachments to come as time allows!

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

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


(mostly) split caching and polling of service directories into seperate web-pages.  cleaned up use of  vs. .  Got everything working as much as possible without having any valid external Services Directories

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


sample data:hl7v3 to v3

sample data:hl7v3 to v3

SVN-Revision: 3248

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


[MOD] Chat: (dis)connection & timeout handling


eXist builtin functions - add compression module function signatures.

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

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 compression:gzip($data as xs:base64Binary) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function compression:tar($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean) as xs:base64Binary* external;
declare %a:since("exist", "4.4") function compression:tar($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string) as xs:base64Binary* external;
declare %a:since("exist", "4.4") function compression:tar($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string, $encoding as xs:string) as xs:base64Binary* external;
declare %a:since("exist", "4.4") function compression:ungzip($gzip-data as xs:base64Binary) as xs:base64Binary? external;
declare %a:since("exist", "4.4") function compression:untar($tar-data as xs:base64Binary, $entry-filter as function(*), $entry-filter-param as xs:anyType*, $entry-data as function(*), $entry-data-param as xs:anyType*) as item()* external;
declare %a:since("exist", "4.4") function compression:untar($tar-data as xs:base64Binary, $entry-filter as function(*), $entry-filter-param as xs:anyType*, $entry-data as function(*), $entry-data-param as xs:anyType*, $encoding as xs:string) as item()* external;
declare %a:since("exist", "4.4") function compression:unzip($zip-data as xs:base64Binary, $entry-filter as function(*), $entry-filter-param as xs:anyType*, $entry-data as function(*), $entry-data-param as xs:anyType*) as item()* external;
declare %a:since("exist", "4.4") function compression:unzip($zip-data as xs:base64Binary, $entry-filter as function(*), $entry-filter-param as xs:anyType*, $entry-data as function(*), $entry-data-param as xs:anyType*, $encoding as xs:string) as item()* external;
declare %a:since("exist", "4.4") function compression:zip($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean) as xs:base64Binary* external;
declare %a:since("exist", "4.4") function compression:zip($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string) as xs:base64Binary* external;
declare %a:since("exist", "4.4") function compression:zip($sources as xs:anyType+, $use-collection-hierarchy as xs:boolean, $strip-prefix as xs:string, $encoding as xs:string) as xs:base64Binary* external;

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


Add datasetStatus query.

Add datasetStatus query.

; datasetStatus
(fn [dataset]
	 (query {:select [:status :text] :from [:dataset] :where [:= :name dataset]}))

error: pathspec 'js/queries/datasetStatus.xq' did not match any file(s) known to git


Add missing file for xqDoc generation.

Add missing file for xqDoc generation.

module namespace doc2html = "http://www.zorba-xquery.com/modules/xqdoc2html";

import module namespace file = "http://www.zorba-xquery.com/modules/file";
import module namespace xqd = "http://www.zorba-xquery.com/modules/xqdoc";

import module namespace xqdg = "http://www.zorba-xquery.com/modules/internal/xqdoc-xhtml" at "xqdoc-xhtml.xq";

import schema namespace xqdoc = "http://www.xqdoc.org/1.0" at "xqdoc-1.0.xsd";

declare copy-namespaces preserve, inherit;

(:~
 : This variable contains the relative paths to directories that contain
 : example code fragments that are included.
 :)
declare variable $doc2html:examplePath as xs:string* := (
    'test/rbkt/Queries/zorba',
    'test/update/Queries',
    'test/rbkt/ExpQueryResults/zorba',
    'test/update/ExpectedTestResults'
);

declare variable $doc2html:table :=
;

declare variable $doc2html:stepBacks as xs:string := "../../../../../../../../../../../../../../../../../../../../";

(:~
 : This variable contains the to the index.html main page
 :)

declare variable $doc2html:indexCollector := <modules/>;

declare function doc2html:getFileName($moduleURI as xs:string) as xs:string
{
    replace(
        replace($moduleURI, "/", "_"),
        "http:__",
        ""
    )
};

declare sequential function doc2html:clearFolder($folderPath as xs:string, $pattern as xs:string) as xs:string*
{
  if(fn:not(file:exists($folderPath))) then
    ""
  else
    for $file in file:files($folderPath, $pattern, fn:true())
    let $filePath := fn:concat($folderPath, file:path-separator(), $file)
    return
      try {
        file:remove($filePath);
        concat("
  SUCCESS: ", $filePath);
      } catch * ($error_code) {
        concat("
  FAILED: ", $filePath)
      }
};

(:~
 : This function generates the XQDoc XML for all the modules found in $modulesPath
 : and writes the resulting XML documents in $targetPath. The hierarchy is preserved.
 :
 : @param $modulePath where to search for modules recursively.
 : @param $targetPath where to generate the XQDoc XML documents.
 : @return The function returns a string sequence with a status messge for each
 :         module processed.
 :)
declare sequential function doc2html:generateXQDocXml(
  $modulesPath as xs:string, $xqdocXmlPath as xs:string
) as xs:string* {
  for $filedirs in tokenize($modulesPath, ";")
  for $file in file:files($filedirs, "\.xq$", fn:true())
  let $filePath := fn:concat($filedirs, file:path-separator(), $file)
  let $xqdoc := xqd:xqdoc(file:path-to-uri($filePath))
  let $moduleDoc := $xqdoc/xqdoc:module
  let $moduleName := $moduleDoc/xqdoc:name
  let $moduleUri := $moduleDoc/xqdoc:uri
  return
    try {
      file:mkdirs($xqdocXmlPath, false());
      let $x := fn:count(file:files($xqdocXmlPath, "\.xml$", fn:true())) + 1
      let $xqdocFileName := fn:concat($xqdocXmlPath, file:path-separator(), doc2html:getFileName($moduleUri), ".xml")
      return
      file:write($xqdocFileName, $xqdoc, <s method="xml" indent="yes" />/@*);
      concat("
SUCCESS: ", $moduleUri, " (", ()(:$xqdocFileName:), ")");
    } catch * ($error_code) {
      concat("
FAILED: ", $moduleUri, " (", ()(:$xqdocFileName:), ")")
    }
};

(:~
 : This function removes the internal functionality from an XQDoc XML node.
 :
 : @param $xqdoc The XQDdoc XML node to remove the functionality from.
 : @return The xqdoc node without the internal functionality.
 :)
declare sequential function doc2html:removeInternalFunctionality($xqdoc as node()) as node() {
  delete node $xqdoc/xqdoc:functions/xqdoc:function[fn:starts-with(fn:data(xqdoc:comment/xqdoc:description), "Helper function")];
  $xqdoc;
};

(:~
 : This function generates the XQDoc XHTML pages for all the XQDoc XML
 : documents found in $xqdocPath and writes the resulting pages to in
 : $targetPath. The hierarchy is preserved.
 :
 : @param $indexPath path to the XHTML index page.
 :)
declare sequential function doc2html:generateXQDocXhtml(
  $indexPath      as xs:string, $xqdocXmlPath   as xs:string,
  $xqdocXhtmlPath as xs:string, $leftMenu as element(menu),
  $modulesPath    as xs:string
) as xs:string* {
  let $indexHtmlDoc := file:read-xml($indexPath)
  return
  for $file in file:files($xqdocXmlPath, "\.xml$", fn:true())
  let $stepsFromIndex := fn:count(fn:tokenize($file, fn:concat("\", file:path-separator()))) - 2
  let $xmlFilePath := concat($xqdocXmlPath, file:path-separator(), $file)
  let $xhtmlFilePath := concat($xqdocXhtmlPath, file:path-separator(), fn:replace($file, "\.xml$", ".html"))
  let $xhtmlFileDir :=
    let $segments := fn:tokenize($xhtmlFilePath, fn:concat("\", file:path-separator()))
    let $lastSegm := $segments[fn:count($segments)]
    return fn:substring-before($xhtmlFilePath, $lastSegm)
  return
    try {
      let $xqdoc := doc2html:removeInternalFunctionality(file:read-xml($xmlFilePath)/xqdoc:xqdoc)
      let $moduleDoc := $xqdoc/xqdoc:module
      let $moduleName := $moduleDoc/xqdoc:name
      let $moduleUri := $moduleDoc/xqdoc:uri
      let $menu :=
XQuery Libraries

      let $menu := doc2html:createLeftMenu($menu, $moduleUri, $leftMenu)
      let $xhtml := xqdg:doc($xqdoc, $menu)
      return block {
        file:mkdirs($xhtmlFileDir, false());

        doc2html:configure-xhtml($xhtml, $stepsFromIndex, $modulesPath);

        file:write($xhtmlFilePath, $xhtml, <s method="xhtml" indent="yes" />/@*);

        concat("
SUCCESS: ", $moduleUri, " (", $xhtmlFilePath, ")");
      }
    } catch * ($error_code) {
      concat("
FAILED: ", $xhtmlFilePath)
    }
};

(:~
 : This function gathers the names of the XQDoc XHTML pages for all the XQDoc XML
 : documents found in $xqdocXmlPath. The hierarchy is preserved.
 :)
declare sequential function doc2html:gatherModules(
  $xqdocXmlPath as xs:string
){
  for $file in file:files($xqdocXmlPath, "\.xml$", fn:true())
  let $xmlFilePath := concat($xqdocXmlPath, file:path-separator(), $file)
  let $xhtmlRelativeFilePath := fn:replace($file, "\.xml$", ".html")
  let $xhtmlRelativeFilePathSlash := fn:replace($xhtmlRelativeFilePath, fn:concat("\", file:path-separator()), "/")
  return
  try {
      let $xqdoc := doc2html:removeInternalFunctionality(file:read-xml($xmlFilePath)/xqdoc:xqdoc)
      let $moduleDoc := $xqdoc/xqdoc:module
      let $moduleUri := $moduleDoc/xqdoc:uri
      return block {
        doc2html:collectModule($moduleDoc, $xhtmlRelativeFilePath);
        concat("
SUCCESS: ", $moduleUri, " (", $xmlFilePath, ")");
      }
    } catch * ($error_code) {
      concat("
FAILED: ", $xmlFilePath)
    }
};

declare sequential function doc2html:collectModule ($module, $relativeFileName as xs:string) {
    let $moduleName := $module/xqdoc:name,
        $moduleUri := $module/xqdoc:uri
    return
        insert node <module uri="{$moduleUri/text()}" file="{$relativeFileName}" /> as last into $doc2html:indexCollector;
    ();
};

(:~
 : This function returns the left menu needed in the index.html and also all the XHTML module pages.
 :
 :)
declare sequential function doc2html:createLeftMenu($menu, $moduleUri, $categories)
{
  for $cat1 in $categories/category
  let $last1 := if(fn:exists($cat1/@last)) then fn:boolean(fn:data($cat1/@last)) else fn:false()
  return block {
    doc2html:createCategory($menu, $moduleUri, $cat1, $last1);
    for $cat2 in $cat1/category
    let $last2 := if(fn:exists($cat2/@last)) then fn:boolean(fn:data($cat2/@last)) else fn:false()
    let $menu2 := $menu/li[fn:last()]/ul
    return block {
      doc2html:createCategory($menu2, $moduleUri, $cat2, $last2);
      for $cat3 in $cat2/category
      let $last3 := if(fn:exists($cat3/@last)) then fn:boolean(fn:data($cat3/@last)) else fn:false()
      let $menu3 := $menu/li[fn:last()]/ul/li[fn:last()]/ul
      return block {
        doc2html:createCategory($menu3, $moduleUri, $cat3, $last3);
      };
    };
  };

  $menu;

};

(:~
 : This is a helper function used to add a category and the modules belonging to it to a node in the menu
 :
 : @param $menu the node in the menu where the new category will be added as the last node
 : @param $moduleUri the name of this module will be highlighted in red as this is the current selected item in the menu
 : @param $category the node in the $leftMenu variable that will be added to the $menu
 : @param $last bool indicating if this is the last item in the $menu node needed in order to set the treeview control
 :)
declare sequential function doc2html:createCategory($menu, $moduleUri, $category, $last as xs:boolean)
{
  block {
  if($last) then
    insert nodes

{' '}

    {data($category/@name)}

    {
     for $module in $doc2html:indexCollector/module
      order by fn:data($module/@uri)
      return block {
        if(fn:starts-with(fn:string($module/@uri),data($category/@uri))
           and fn:not(fn:contains (fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/')),'/'))
           and fn:not($module/@uri = $moduleUri)) then

{fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/'))}

        else if(fn:starts-with(fn:string($module/@uri),data($category/@uri))
                and fn:not(fn:contains (fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/')),'/'))
                and ($module/@uri = $moduleUri)) then

{fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/'))}

        else ()
        };
    }

    as last into $menu
  else
    insert nodes

{' '}

    {data($category/@name)}

    {
      for $module in $doc2html:indexCollector/module
      order by fn:data($module/@uri)
      return block {
        if(fn:starts-with(fn:string($module/@uri),data($category/@uri))
           and fn:not(fn:contains (fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/')),'/'))
           and fn:not($module/@uri = $moduleUri)) then

{fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/'))}

        else if(fn:starts-with(fn:string($module/@uri),data($category/@uri))
                and fn:not(fn:contains (fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/')),'/'))
                and ($module/@uri = $moduleUri)) then

{fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/'))}

        else ()
        };
    }

    as last into $menu
    };

   $menu;
};

declare sequential function doc2html:getFilePath (
  $filename as xs:string, $modulesPath as xs:string
) as xs:string* {
  let $zorbaPath := replace($modulesPath,"/modules","")
  for $relPath in $doc2html:examplePath
  let $path := concat($zorbaPath,'/',$relPath)
  let $test := file:files($path,concat("^",$filename,"$"),fn:true())[1]
  return
  if (fn:exists($test)) then
    $test
  else
    ()
};

declare function doc2html:get-path-to-index ($stepsBack) as xs:string
{
  (: Error prone: stepsBack > stepBacks :)
  fn:substring($doc2html:stepBacks, 1, 3 * $stepsBack)
};

declare sequential function doc2html:configure-xhtml (
  $xhtml, $stepsFromIndex as xs:integer,
  $modulesPath as xs:string
) {
  let $pathToIndex := doc2html:get-path-to-index($stepsFromIndex)
  return
  (: replace the <test> nodes with eiter links to the actual files or inline the actual files based on the 'type' attribute value :)
  for $file in $xhtml//*:include
  let $type := $file/@type
  let $path := doc2html:getFilePath($file/text(), $modulesPath)
  let $read_text := file:read-text($path)
  return block {
  (: at the moment there is no way to ship the files defined as links with the packages/installers
    if (matches($type, "link")) then
      replace node $file with {$path}
    else :)
    if (matches($type, "inline")) then
      replace node $file with
        if (fn:exists($path)) then

 {$path}:

{$read_text}

        else

No example matching pattern '{$file/text()}' was found. Please update 'examplePath' variable.

        else ()
  };

  (: replace the function type description with images :)
  let $xquSpec := "http://www.w3.org/TR/xquery-update-10/",
      $xqsSpec := "http://www.w3.org/TR/xquery-sx-10/#dt-sequential-function",
      $xq11Spec := "http://www.w3.org/TR/xquery-11/#FunctionDeclns"
  let $pathToIndex := doc2html:get-path-to-index($stepsFromIndex)
  let $imagesPath := concat($pathToIndex, "images/")
  for $typeTd in $xhtml//*:td
  where $typeTd/@class eq "type"
  let $type := $typeTd/text()
  return block {
    if (matches($type, "updating")) then
      replace node $typeTd/text() with

    else if (matches($type, "sequential")) then
      replace node $typeTd/text() with

    else if (matches($type, "nondeterministic")) then
      replace node $typeTd/text() with

    else ();
  };

  $xhtml;
};

declare sequential function doc2html:createModuleTable($leftMenu as element(menu)) {
  for $cat1 in $leftMenu/category
  return block {
    doc2html:createModuleHelper($doc2html:table, $cat1);
    for $cat2 in $cat1/category
    let $table2 := $doc2html:table/li[fn:last()]/ul
    return block {
      doc2html:createModuleHelper($table2, $cat2);
      for $cat3 in $cat2/category
      let $table3 := $doc2html:table/li[fn:last()]/ul/li[fn:last()]/ul
      return block {
        doc2html:createModuleHelper($table3, $cat3);
      };
    };
  };

  $doc2html:table;
};

declare sequential function doc2html:createModuleHelper($table, $category)
{
  block {
    insert nodes
{data($category/@name)}

    {
     for $module in $doc2html:indexCollector/module
      order by fn:data($module/@uri)
      return
        if(fn:starts-with(fn:string($module/@uri),data($category/@uri))
           and fn:not(fn:contains (fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/')),'/'))) then

{fn:substring-after(data($module/@uri),fn:concat(data($category/@uri),'/'))}

        else ()
    }

    as last into $table
    };

   $table;
};

(:~
 : This function reads, updates and returns the new index.html.
 :
 : @param $indexPath Where to search for XML XQDoc documents recursively.
 : @return The content of the new index.html.
 :)
declare sequential function doc2html:generateIndexHtml($indexPath as xs:string, $menu, $modules) as document-node() {
    let $indexHtmlDoc := file:read-xml($indexPath)
    return block {
        insert nodes $menu
        as last into $indexHtmlDoc/*:html/*:body/*:div[@id='main']/*:div[@id='leftMenu'];

        let $module_list := $indexHtmlDoc/*:html/*:body/*:div[@id='main']/*:div[@id='rightcontent']/*:div[@id='module_list']
        return
          if ($module_list)
          then
            insert node $modules as last into $module_list
          else
            ();

        $indexHtmlDoc;
    }
};

declare sequential function doc2html:main(
  $modulePath as xs:string, $xqdocBuildPath as xs:string,
  $indexHtmlPath as xs:string
) {
  let $leftMenu :=
  <menu>
  <category name="http://expath.org/ns" uri="http://expath.org/ns" />
  <category name="http://www.zorba-xquery.com/modules" uri="http://www.zorba-xquery.com/modules">
    <category name="email" uri="http://www.zorba-xquery.com/modules/email" />
    <category name="excel" uri="http://www.zorba-xquery.com/modules/excel" />
    <category name="image" uri="http://www.zorba-xquery.com/modules/image" />
    <category name="introspection" uri="http://www.zorba-xquery.com/modules/introspection" />
    <category name="security" uri="http://www.zorba-xquery.com/modules/security" />
    <category name="oauth" uri="http://www.zorba-xquery.com/modules/oauth" />
    <category name="webservices" uri="http://www.zorba-xquery.com/modules/webservices" last="true">
      <category name="google" uri="http://www.zorba-xquery.com/modules/webservices/google" />
      <category name="yahoo" uri="http://www.zorba-xquery.com/modules/webservices/yahoo" last="true" />
    </category>
  </category>
  <category name="http://www.w3.org/2005" uri="http://www.w3.org/2005" last="true"/>
  </menu>
  let $menu :=

      XQuery Libraries

  return doc2html:main($menu, $leftMenu, $modulePath, $xqdocBuildPath, $indexHtmlPath)
};

declare sequential function doc2html:main(
  $menu as element(ul),  $leftMenu as element(menu),
  $modulePath as xs:string, $xqdocBuildPath as xs:string,
  $indexHtmlPath as xs:string
) {
  declare $xqdocXmlPath   as xs:string := fn:concat($xqdocBuildPath, file:path-separator(), "xml");
  declare $xqdocXhtmlPath as xs:string := fn:concat($xqdocBuildPath, file:path-separator(), "xhtml");

  (: generate the XQDoc XML for all the modules :)
  if (file:mkdirs($xqdocXmlPath, false())) then
  (
    doc2html:clearFolder($xqdocXmlPath,"\.xml$"),
    doc2html:generateXQDocXml($modulePath, $xqdocXmlPath)
  )
  else
    error()
  ;

  (: generate the XQDoc XHTML for all the modules :)
  let $absoluteXhtmlDir := concat($xqdocBuildPath, "/xhtml")
  return
  if (file:mkdirs($absoluteXhtmlDir, false())) then
  (
    doc2html:clearFolder($xqdocXhtmlPath,"xqdoc\.html$"),
    doc2html:gatherModules($xqdocXmlPath),
    doc2html:generateXQDocXhtml($indexHtmlPath, $xqdocXmlPath, $xqdocXhtmlPath, $leftMenu, $modulePath)
  )
  else
    error()
  ;

  let $menu := doc2html:createLeftMenu($menu, "index.html", $leftMenu)
  let $modules := doc2html:createModuleTable($leftMenu)
  let $doc := doc2html:generateIndexHtml($indexHtmlPath, $menu, $modules)
  return doc2html:configure-xhtml($doc/*:html, 0, $modulePath)
  ;
};

error: pathspec 'doc/zorba/xqdoc/src/xqdoc-lib.xq' did not match any file(s) known to git


Add BaseX crypto module function signatures.

xquery version "3.0";

(:~
: User: bridger
: Date: 9/22/18
: Time: 3:39 PM
: To change this template use File | Settings | File Templates.
:)

module namespace crypto = "http://expath.org/ns/crypto";

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

declare %a:since("basex", "7.0") function crypto:hmac($message as xs:string, $key as xs:anyAtomicType, $algorithm as xs:string) as xs:base64Binary (: $key as [7.0]xs:string [8.6]xs:anyAtomicType :) external;
declare %a:since("basex", "7.0") function crypto:hmac($message as xs:string, $key as xs:anyAtomicType, $algorithm as xs:string, $encoding as xs:string) as xs:base64Binary (: $key as [7.0]xs:string [8.6]xs:anyAtomicType :) external;

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


Added xq file expressing query 2 using XQuery

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

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


needed for AtomFeeds.java!!!

needed for AtomFeeds.java!!!

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

declare namespace atom="http://www.w3.org/2005/Atom";

let $feed := /atom:feed
return element atom:feed{
    $feed/@*, $feed/*,
    for $entry in collection(string-join((substring-before(base-uri($feed),'/.feed.atom'),".feed.entry"),"/"))/atom:entry
    order by xs:dateTime($entry/published) descending
    return $entry
}

error: pathspec 'src/org/exist/atom/modules/get-feed.xq' did not match any file(s) known to git


Added quality filtering query to give lists of records which are missing a certain kind of information

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()//h1[not(root()//*[notes:filterbytype(.,$type)])] return
{string($heading)} {notes:paperlinks($heading)}
}

)

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