A query to read the results of https://gist.github.com/joewiz/4ce1a564553d954855fe7500989afe22 and generate a report about function signature mismatches between the W3C XPath & XQuery Functions & Operators spec and eXist's implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
import module namespace versions="http://exist-db.org/apps/public-repo/versions" at "/db/apps/public-repo/modules/versions.xqm"; | |
let $exist-versions := ("4.11.0", "5.5.1", "6.1.0") | |
let $abbrevs := ("shared-resources", "dashboard", "doc", "eXide", "functx", "fundocs", "markdown", "monex", "usermanager") | |
let $header-row := ("package", $exist-versions ! ("eXist " || .)) => string-join(", ") | |
let $body-rows := | |
for $abbrev in $abbrevs | |
let $packages := doc("/db/apps/public-repo-data/metadata/package-groups.xml")//package-group[abbrev = $abbrev]//package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; | |
declare namespace pkg="http://expath.org/ns/pkg"; | |
declare option output:method "html"; | |
declare option output:html-version "5.0"; | |
declare option output:media-type "text/html"; | |
declare function local:sort-packages($packages as element(pkg:package)*) as element(pkg:package)* { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(: Note: the environment-variable functions only work if the user running the query has DBA access :) | |
(: Probe available environment variables with the following query :) | |
(: | |
map:merge( | |
available-environment-variables() ! map:entry(., environment-variable(.)) | |
), | |
:) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
declare function local:strip-diacritics($string as xs:string) as xs:string { | |
$string | |
=> normalize-unicode("NFD") | |
=> replace("\p{IsCombiningDiacriticalMarks}", "") | |
}; | |
declare function local:inspect-diacritics($string as xs:string) as element() { | |
let $normalized := normalize-unicode($string, "NFD") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
module namespace r = "http://joewiz.org/ns/xquery/roman-numerals"; | |
(: Converts standard Roman numerals to integers. | |
: Handles additive and subtractive but not double subtractive. | |
: Case insensitive. | |
: Doesn't attempt to validate a numeral other than a naïve character check. | |
: See discussion of standard modern Roman numerals at: | |
: http://en.wikipedia.org/wiki/Roman_numerals. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(: doesn't support YAML indentation yet - just a start :) | |
declare function local:process-yaml-value($value) { | |
let $single-quote := "^'(.+)'$" | |
let $double-quote := '^"(.+)"$' | |
return | |
if (matches($value, $single-quote) or matches($value, $double-quote)) then | |
let $pattern := "^['""](.+)['""]$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(:~ | |
Calculate Levenshtein Distance, using XQuery | |
@author Guillaume Mella | |
@see http://apps.jmmc.fr/~mellag/xquery/levenshtein/2018/01/19/xquery-levenshtein-distance/ | |
:) | |
declare function local:levenshtein-distance($string1 as xs:string?, $string2 as xs:string?) | |
as xs:integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
declare namespace fos="http://www.w3.org/xpath-functions/spec/namespace"; | |
declare function local:writeHeader() as xs:string { | |
' | |
xquery version "3.1"; | |
module namespace xqfunctions="http://exist-db.org/xquery/test/xqfunctions"; |