Skip to content

Instantly share code, notes, and snippets.

@joewiz
Last active April 1, 2020 15:18
Show Gist options
  • Save joewiz/acb0558f078c0576a5e7 to your computer and use it in GitHub Desktop.
Save joewiz/acb0558f078c0576a5e7 to your computer and use it in GitHub Desktop.
Compare XPath functions in W3C spec vs. eXist 3.4.0
xquery version "3.1";
element modules {
util:registered-modules()[starts-with(., 'http://www.w3')] !
element module {
element namespace-uri {.},
util:registered-functions(.) !
element function {.}
}
}
<modules>
<module>
<namespace-uri>http://www.w3.org/2005/xpath-functions/array</namespace-uri>
<function>array:append</function>
<function>array:filter</function>
<function>array:flatten</function>
<function>array:fold-left</function>
<function>array:fold-right</function>
<function>array:for-each</function>
<function>array:for-each-pair</function>
<function>array:get</function>
<function>array:head</function>
<function>array:insert-before</function>
<function>array:join</function>
<function>array:remove</function>
<function>array:reverse</function>
<function>array:size</function>
<function>array:subarray</function>
<function>array:tail</function>
</module>
<module>
<namespace-uri>http://www.w3.org/2005/xpath-functions/math</namespace-uri>
<function>acos</function>
<function>asin</function>
<function>atan</function>
<function>atan2</function>
<function>cos</function>
<function>exp</function>
<function>exp10</function>
<function>log</function>
<function>log10</function>
<function>pi</function>
<function>pow</function>
<function>sin</function>
<function>sqrt</function>
<function>tan</function>
</module>
<module>
<namespace-uri>http://www.w3.org/2005/xpath-functions</namespace-uri>
<function>QName</function>
<function>abs</function>
<function>adjust-date-to-timezone</function>
<function>adjust-dateTime-to-timezone</function>
<function>adjust-time-to-timezone</function>
<function>analyze-string</function>
<function>apply</function>
<function>available-environment-variables</function>
<function>avg</function>
<function>base-uri</function>
<function>boolean</function>
<function>ceiling</function>
<function>codepoint-equal</function>
<function>codepoints-to-string</function>
<function>collection</function>
<function>compare</function>
<function>concat</function>
<function>contains</function>
<function>count</function>
<function>current-date</function>
<function>current-dateTime</function>
<function>current-time</function>
<function>data</function>
<function>dateTime</function>
<function>day-from-date</function>
<function>day-from-dateTime</function>
<function>days-from-duration</function>
<function>deep-equal</function>
<function>default-collation</function>
<function>distinct-values</function>
<function>doc</function>
<function>doc-available</function>
<function>document-uri</function>
<function>empty</function>
<function>encode-for-uri</function>
<function>ends-with</function>
<function>environment-variable</function>
<function>equals</function>
<function>error</function>
<function>escape-html-uri</function>
<function>escape-uri</function>
<function>exactly-one</function>
<function>exists</function>
<function>false</function>
<function>filter</function>
<function>floor</function>
<function>fold-left</function>
<function>fold-right</function>
<function>for-each</function>
<function>for-each-pair</function>
<function>format-date</function>
<function>format-dateTime</function>
<function>format-number</function>
<function>format-time</function>
<function>function-arity</function>
<function>function-lookup</function>
<function>function-name</function>
<function>generate-id</function>
<function>has-children</function>
<function>head</function>
<function>hours-from-dateTime</function>
<function>hours-from-duration</function>
<function>hours-from-time</function>
<function>id</function>
<function>idref</function>
<function>implicit-timezone</function>
<function>in-scope-prefixes</function>
<function>index-of</function>
<function>innermost</function>
<function>insert-before</function>
<function>iri-to-uri</function>
<function>json-doc</function>
<function>lang</function>
<function>last</function>
<function>load-xquery-module</function>
<function>local-name</function>
<function>local-name-from-QName</function>
<function>lower-case</function>
<function>map</function>
<function>map-pairs</function>
<function>matches</function>
<function>max</function>
<function>min</function>
<function>minutes-from-dateTime</function>
<function>minutes-from-duration</function>
<function>minutes-from-time</function>
<function>month-from-date</function>
<function>month-from-dateTime</function>
<function>months-from-duration</function>
<function>name</function>
<function>namespace-uri</function>
<function>namespace-uri-for-prefix</function>
<function>namespace-uri-from-QName</function>
<function>nilled</function>
<function>node-name</function>
<function>normalize-space</function>
<function>normalize-unicode</function>
<function>not</function>
<function>number</function>
<function>one-or-more</function>
<function>outermost</function>
<function>parse-json</function>
<function>parse-xml</function>
<function>parse-xml-fragment</function>
<function>position</function>
<function>prefix-from-QName</function>
<function>remove</function>
<function>replace</function>
<function>resolve-QName</function>
<function>resolve-uri</function>
<function>reverse</function>
<function>root</function>
<function>round</function>
<function>round-half-to-even</function>
<function>seconds-from-dateTime</function>
<function>seconds-from-duration</function>
<function>seconds-from-time</function>
<function>serialize</function>
<function>sort</function>
<function>starts-with</function>
<function>static-base-uri</function>
<function>string</function>
<function>string-join</function>
<function>string-length</function>
<function>string-to-codepoints</function>
<function>subsequence</function>
<function>substring</function>
<function>substring-after</function>
<function>substring-before</function>
<function>sum</function>
<function>tail</function>
<function>timezone-from-date</function>
<function>timezone-from-dateTime</function>
<function>timezone-from-time</function>
<function>tokenize</function>
<function>trace</function>
<function>translate</function>
<function>true</function>
<function>unordered</function>
<function>upper-case</function>
<function>year-from-date</function>
<function>year-from-dateTime</function>
<function>years-from-duration</function>
<function>zero-or-one</function>
</module>
<module>
<namespace-uri>http://www.w3.org/2005/xpath-functions/map</namespace-uri>
<function>map:contains</function>
<function>map:entry</function>
<function>map:for-each</function>
<function>map:for-each-entry</function>
<function>map:get</function>
<function>map:keys</function>
<function>map:merge</function>
<function>map:new</function>
<function>map:put</function>
<function>map:remove</function>
<function>map:size</function>
</module>
</modules>
xquery version "3.1";
declare namespace fos="http://www.w3.org/xpath-functions/spec/namespace";
element modules {
let $all-functions := hc:send-request(<hc:request href='https://www.w3.org/TR/2017/REC-xpath-functions-31-20170321/function-catalog.xml' method='get'/>)[2]//fos:function[@prefix ne 'op']
for $functions in $all-functions
group by $namespace-prefix := $functions/@prefix
return
element module {
element namespace-prefix { $namespace-prefix },
for $function in $functions
order by $function/@name
return
element function { $function/@name/string() }
}
}
<modules>
<module>
<namespace-prefix prefix="array"/>
<function>append</function>
<function>filter</function>
<function>flatten</function>
<function>fold-left</function>
<function>fold-right</function>
<function>for-each</function>
<function>for-each-pair</function>
<function>get</function>
<function>head</function>
<function>insert-before</function>
<function>join</function>
<function>put</function>
<function>remove</function>
<function>reverse</function>
<function>size</function>
<function>sort</function>
<function>subarray</function>
<function>tail</function>
</module>
<module>
<namespace-prefix prefix="math"/>
<function>acos</function>
<function>asin</function>
<function>atan</function>
<function>atan2</function>
<function>cos</function>
<function>exp</function>
<function>exp10</function>
<function>log</function>
<function>log10</function>
<function>pi</function>
<function>pow</function>
<function>sin</function>
<function>sqrt</function>
<function>tan</function>
</module>
<module>
<namespace-prefix prefix="fn"/>
<function>QName</function>
<function>abs</function>
<function>adjust-date-to-timezone</function>
<function>adjust-dateTime-to-timezone</function>
<function>adjust-time-to-timezone</function>
<function>analyze-string</function>
<function>apply</function>
<function>available-environment-variables</function>
<function>avg</function>
<function>base-uri</function>
<function>boolean</function>
<function>ceiling</function>
<function>codepoint-equal</function>
<function>codepoints-to-string</function>
<function>collation-key</function>
<function>collection</function>
<function>compare</function>
<function>concat</function>
<function>contains</function>
<function>contains-token</function>
<function>count</function>
<function>current-date</function>
<function>current-dateTime</function>
<function>current-time</function>
<function>data</function>
<function>dateTime</function>
<function>day-from-date</function>
<function>day-from-dateTime</function>
<function>days-from-duration</function>
<function>deep-equal</function>
<function>default-collation</function>
<function>default-language</function>
<function>distinct-values</function>
<function>doc</function>
<function>doc-available</function>
<function>document-uri</function>
<function>element-with-id</function>
<function>empty</function>
<function>encode-for-uri</function>
<function>ends-with</function>
<function>environment-variable</function>
<function>error</function>
<function>escape-html-uri</function>
<function>exactly-one</function>
<function>exists</function>
<function>false</function>
<function>filter</function>
<function>floor</function>
<function>fold-left</function>
<function>fold-right</function>
<function>for-each</function>
<function>for-each-pair</function>
<function>format-date</function>
<function>format-dateTime</function>
<function>format-integer</function>
<function>format-number</function>
<function>format-time</function>
<function>function-arity</function>
<function>function-lookup</function>
<function>function-name</function>
<function>generate-id</function>
<function>has-children</function>
<function>head</function>
<function>hours-from-dateTime</function>
<function>hours-from-duration</function>
<function>hours-from-time</function>
<function>id</function>
<function>idref</function>
<function>implicit-timezone</function>
<function>in-scope-prefixes</function>
<function>index-of</function>
<function>innermost</function>
<function>insert-before</function>
<function>iri-to-uri</function>
<function>json-doc</function>
<function>json-to-xml</function>
<function>lang</function>
<function>last</function>
<function>load-xquery-module</function>
<function>local-name</function>
<function>local-name-from-QName</function>
<function>lower-case</function>
<function>matches</function>
<function>max</function>
<function>min</function>
<function>minutes-from-dateTime</function>
<function>minutes-from-duration</function>
<function>minutes-from-time</function>
<function>month-from-date</function>
<function>month-from-dateTime</function>
<function>months-from-duration</function>
<function>name</function>
<function>namespace-uri</function>
<function>namespace-uri-for-prefix</function>
<function>namespace-uri-from-QName</function>
<function>nilled</function>
<function>node-name</function>
<function>normalize-space</function>
<function>normalize-unicode</function>
<function>not</function>
<function>number</function>
<function>one-or-more</function>
<function>outermost</function>
<function>parse-ietf-date</function>
<function>parse-json</function>
<function>parse-xml</function>
<function>parse-xml-fragment</function>
<function>path</function>
<function>position</function>
<function>prefix-from-QName</function>
<function>random-number-generator</function>
<function>remove</function>
<function>replace</function>
<function>resolve-QName</function>
<function>resolve-uri</function>
<function>reverse</function>
<function>root</function>
<function>round</function>
<function>round-half-to-even</function>
<function>seconds-from-dateTime</function>
<function>seconds-from-duration</function>
<function>seconds-from-time</function>
<function>serialize</function>
<function>sort</function>
<function>starts-with</function>
<function>static-base-uri</function>
<function>string</function>
<function>string-join</function>
<function>string-length</function>
<function>string-to-codepoints</function>
<function>subsequence</function>
<function>substring</function>
<function>substring-after</function>
<function>substring-before</function>
<function>sum</function>
<function>tail</function>
<function>timezone-from-date</function>
<function>timezone-from-dateTime</function>
<function>timezone-from-time</function>
<function>tokenize</function>
<function>trace</function>
<function>transform</function>
<function>translate</function>
<function>true</function>
<function>unordered</function>
<function>unparsed-text</function>
<function>unparsed-text-available</function>
<function>unparsed-text-lines</function>
<function>upper-case</function>
<function>uri-collection</function>
<function>xml-to-json</function>
<function>year-from-date</function>
<function>year-from-dateTime</function>
<function>years-from-duration</function>
<function>zero-or-one</function>
</module>
<module>
<namespace-prefix prefix="map"/>
<function>contains</function>
<function>entry</function>
<function>find</function>
<function>for-each</function>
<function>get</function>
<function>keys</function>
<function>merge</function>
<function>put</function>
<function>remove</function>
<function>size</function>
</module>
</modules>
@joewiz
Copy link
Author

joewiz commented Aug 2, 2017

As of eXist 3.4.0:

Unique to W3C list:

  • array:put
  • array:sort
  • fn:collation-key
  • fn:contains-token
  • fn:default-language
  • fn:element-with-id
  • fn:format-integer
  • fn:json-to-xml
  • fn:outermost
  • fn:parse-ietf-date
  • fn:path
  • fn:random-number-generator
  • fn:transform
  • fn:unparsed-text
  • fn:unparsed-text-available
  • fn:unparsed-text-lines
  • fn:uri-collection
  • fn:xml-to-json
  • map:find

Unique to eXist

  • fn:equals
  • fn:escape-uri
  • fn:map
  • fn:map-pairs
  • map:for-each-entry
  • map:new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment