Skip to content

Instantly share code, notes, and snippets.

@windauer
Last active December 10, 2015 22:29
Show Gist options
  • Save windauer/4502578 to your computer and use it in GitHub Desktop.
Save windauer/4502578 to your computer and use it in GitHub Desktop.
Various XQuery Snippets

index stuff

reindex

xmldb:reindex("/path/to/collections")

xconf


 <collection xmlns="http://exist-db.org/collection-config/1.0">
    <index xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mods="http://www.loc.gov/mods/v3">
        <fulltext default="none" attributes="false"/>
        <lucene>        
            <text match="@name"/>
            <text match="description"/>
            <text match="comment"/>            
        </lucene>
        <!-- Indexes for parameter files -->
        <create qname="@id" type="xs:string"/>
        <create qname="@source" type="xs:string"/>
        <create qname="@refid" type="xs:string"/>
        <create qname="text" type="xs:string"/>
    </index>
</collection>

XUpdate

Replace

update replace $nodeToReplace with $nodeToInsert

Insert

update insert $entry into $entries

XMLDB

Namespace: port module namespace xmldb="http://exist-db.org/xquery/xmldb";

Groups

  • Check if group exists: xmldb:group-exists($group/@name)
  • Create Group: xmldb:create-group($group/@name, $group/@manager)

Users

  • Check if user exists: xmldb:exists-user($user/@name)
  • Create Group: xmldb:create-user($user/@name, $user/@password, tokenize(data($user/@groups), ' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment