Skip to content

Commit 2490d71

Browse files
authored
SaxonJS upgraded to 3.x (#206)
* Saxon 2.7 upgraded to 3.0 beta Refactoring named template callbacks as XPath functions * Fixed command name * Refactoring named templates as functions * More named template callbacks converted to functions * Moved generic HTTP promises to functions.xsl * Cleanup
1 parent 8714801 commit 2490d71

11 files changed

Lines changed: 6810 additions & 6562 deletions

File tree

generate-sef.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ find ./target/ROOT/static/com/atomgraph -type f -name "*.xsl" -exec sh -c 'xmls
88

99
# compile client.xsl to SEF. The output path is mounted in docker-compose.override.yml
1010

11-
npx xslt3 -t -xsl:./target/ROOT/static/com/atomgraph/linkeddatahub/xsl/client.xsl -export:./target/ROOT/static/com/atomgraph/linkeddatahub/xsl/client.xsl.sef.json -nogo -ns:##html5 -relocate:on
11+
npx xslt3-he -t -xsl:./target/ROOT/static/com/atomgraph/linkeddatahub/xsl/client.xsl -export:./target/ROOT/static/com/atomgraph/linkeddatahub/xsl/client.xsl.sef.json -nogo -ns:##html5 -relocate:on

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
</goals>
347347
<phase>package</phase>
348348
<configuration>
349-
<arguments>xslt3 -t -xsl:${project.build.directory}/${build.warName}${saxon-js.stylesheet} -export:${project.build.directory}/${build.warName}${saxon-js.stylesheet}.sef.json -nogo -ns:##html5 -relocate:on</arguments>
349+
<arguments>xslt3-he -t -xsl:${project.build.directory}/${build.warName}${saxon-js.stylesheet} -export:${project.build.directory}/${build.warName}${saxon-js.stylesheet}.sef.json -nogo -ns:##html5 -relocate:on</arguments>
350350
</configuration>
351351
</execution>
352352
</executions>

src/main/webapp/static/com/atomgraph/linkeddatahub/js/saxon-js/LICENSE.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Version 1.0, June 2020
1+
Version 2.0, December 2024
22

3-
Software: This license applies to the packages "xslt3" and "saxon-js"
4-
distributed via npm (https://www.npmjs.com) and to the modules SaxonJS2.js
5-
and SaxonJS2.rt.js available for download from the Saxonica web site
3+
Software: This license applies to the packages "xslt3-he" and "saxonjs-he"
4+
distributed via npm (https://www.npmjs.com) and to the modules SaxonJS3.js
5+
and SaxonJS3.rt.js available for download from the Saxonica web site
66
(https://www.saxonica.com/).
77

88
Copyright: The copyright in the Software belongs to Saxonica Ltd, except

src/main/webapp/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.js

Lines changed: 0 additions & 4698 deletions
This file was deleted.

src/main/webapp/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.rt.js

Lines changed: 0 additions & 1124 deletions
This file was deleted.

src/main/webapp/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS3.js

Lines changed: 4801 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS3.rt.js

Lines changed: 1192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/view.xsl

Lines changed: 764 additions & 729 deletions
Large diffs are not rendered by default.

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,53 @@ exclude-result-prefixes="#all"
443443
</json:map>
444444
</xsl:variable>
445445
<xsl:variable name="update-json-string" select="xml-to-json($update-xml)" as="xs:string"/>
446-
<xsl:message>
447-
<xsl:value-of select="$update-json-string"/>
448-
</xsl:message>
449446
<xsl:variable name="update-json" select="ixsl:call(ixsl:get(ixsl:window(), 'JSON'), 'parse', [ $update-json-string ])"/>
450447
<xsl:sequence select="ixsl:call($sparql-generator, 'stringify', [ $update-json ])"/>
451448
</xsl:function>
449+
450+
<!-- generic HTTP client promises (SaxonJS 3) -->
451+
452+
<xsl:function name="ldh:send-request" ixsl:updating="yes">
453+
<xsl:param name="request" as="map(*)"/>
454+
<xsl:param name="sleep-result" as="item()?"/> <!-- not used but has to be declared: https://saxonica.plan.io/issues/6727 -->
455+
456+
<ixsl:promise
457+
select="ixsl:http-request($request)"
458+
on-completion="ldh:handle-response($request, ?)"
459+
on-failure="ldh:fail#1"/>
460+
</xsl:function>
461+
462+
<xsl:function name="ldh:handle-response" ixsl:updating="yes">
463+
<xsl:param name="request" as="map(*)"/>
464+
<xsl:param name="response" as="map(*)"/>
465+
<xsl:variable name="default-retry-after" select="1" as="xs:integer"/>
466+
467+
<xsl:choose>
468+
<xsl:when test="$response?status = 429">
469+
<xsl:variable name="retry-after" select="
470+
if (map:contains($response?headers, 'Retry-After'))
471+
then xs:integer($response?headers('Retry-After'))
472+
else $default-retry-after"/>
473+
<ixsl:promise
474+
select="ixsl:sleep($retry-after * 1000)"
475+
on-completion="ldh:send-request($request, ?)"/>
476+
</xsl:when>
477+
<xsl:otherwise>
478+
<!-- Dynamically invoke the callback function -->
479+
<xsl:variable name="callback-name" select="$request('ldh:on-success-function')" as="xs:QName"/>
480+
<xsl:variable name="callback-func" select="function-lookup($callback-name, 2)"/>
481+
482+
<xsl:message>Callback function: <xsl:value-of select="string($callback-name)"/></xsl:message>
483+
484+
<xsl:sequence select="$callback-func($request, $response)"/>
485+
</xsl:otherwise>
486+
</xsl:choose>
487+
</xsl:function>
488+
489+
<xsl:function name="ldh:fail">
490+
<xsl:param name="error" as="map(*)"/>
491+
492+
<xsl:message>ldh:fail $error: <xsl:value-of select="serialize($error, map{ 'method': 'json' })"/></xsl:message>
493+
</xsl:function>
494+
452495
</xsl:stylesheet>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/layout.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ LIMIT 100
389389
<script src="{resolve-uri('static/js/yasqe.js', $ac:contextUri)}" type="text/javascript"></script>
390390
</xsl:if>
391391
<xsl:if test="$load-saxon-js">
392-
<script type="text/javascript" src="{resolve-uri('static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS2.rt.js', $ac:contextUri)}" defer="defer"></script>
392+
<script type="text/javascript" src="{resolve-uri('static/com/atomgraph/linkeddatahub/js/saxon-js/SaxonJS3.rt.js', $ac:contextUri)}" defer="defer"></script>
393393
<script type="text/javascript">
394394
<xsl:text disable-output-escaping="yes">
395395
//&lt;![CDATA[

0 commit comments

Comments
 (0)