Instantly share code, notes, and snippets.

View adaptive-serialization.xq
xquery version "3.1";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "adaptive";
declare option output:indent "yes";
map { "reference": xs:anyURI("https://www.w3.org/TR/xslt-xquery-serialization-31/#adaptive-output") }
View date-parser.xqm
xquery version "3.1";
(:
Various Date String Parser
- Parses various flavors of date strings, returns as xs:dateTime or xs:date
- Key functions: dates:parseDateTime() and dates:parseDate()
- Adapted by Joe Wicentowski from
https://github.com/marklogic-community/commons/blob/master/dates/date-parser.xqy
- Adapted to standard XQuery (instead of the MarkLogic 0.9-ml flavor)
- TODO: test against https://github.com/marklogic-community/commons/blob/master/dates/date-parser-tests.xqy
View create-travels-tsv.xq
xquery version "3.1";
(: Generate a TSV of Travels of President and Secretary of State.
: Assumes https://github.com/HistoryAtState/travels has been installed.
:)
(:~
: A function for constructing a TSV (tab-separated value) file
:
: @param A sequence of column headings
View entities.xql
xquery version "3.1";
(:~ A module containing a lookup table, in the form of a map, for HTML entities
: that aren't defined in XML, and a function for converting HTML entities in
: strings to the appropriate characters. Look up characters via map lookup:
:
: $entities:entities?ograve?character => ò
:
: @author Joe Wicentowski
: @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML
View gaps-between-principals-appointments.xq
xquery version "3.1";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "html5";
declare option output:media-type "text/html";
let $title := "Gaps between appointments of Principal Officers"
let $min-gap := xs:dayTimeDuration("P30D")
let $positions := collection("/db/apps/pocom/positions-principals")/principal-position[not(id = ("ambassador-at-large", "career-ambassador"))]
View functionSignatureTests.xquery
xquery version "3.1";
module namespace xqfunctions="http://exist-db.org/xquery/test/xqfunctions";
import module namespace inspect="http://exist-db.org/xquery/inspection" at "java:org.exist.xquery.functions.inspect.InspectionModule";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare function xqfunctions:cardinality($cardinality as xs:string) as xs:string {
View README.md
View README.md

This gist was prompted by a question on the eXist-open mailing list. See http://markmail.org/message/zudf7qp4pqjx6xhi.

To run these files:

  • Download this gist as a .zip file
  • Uncompress the .zip file
  • Create collection /db/test in eXist
  • Upload the contents of the zip file into the /db/test collection
  • Reindex /db/test with xmldb:reindex("/db/test")
  • Run /db/test/test.xq
View 00-README.md

Basic dynamic web pages, with XQuery and eXist

This self-guided tutorial builds up from a simple "Hello, World!" exercise to a dynamic web page that responds to user input. It uses eXist-db and teaches the basic interface elements of the eXide XQuery IDE for developing XQuery-based applications in eXist.

eXist is a free, open source native XML database. It's a great tool for learning how to query, analyze, and transform your data. Among the various interfaces for working with eXist, one of the most convenient is eXide, a browser-based IDE (integrated development environment) for writing XQuery modules and developing XQuery-based applications on your own computer without installing any additional software. eXide comes pre-installed with eXist and has a number of useful features. We'll just cover the basics here. And once you have something you'd like to turn into a web page, eXist has a built-in web server, so you can develop full-fledged web applications by learning just a few additional functions and tec

View ideas-for-exist-db-app-org-repos.md

Ideas for eXist-db org app repos

Incomplete, draft notes toward a proposal for a consideration by the community during a future community call

Goals

  • Have a common set of best practices for maintaining and releasing quality eXist community apps
  • Help maintainers know what they should do
  • Help users know how to report problems, ask questions, and contribute
  • Help the community stay aware of releases