Skip to content

Commit

Permalink
Use @use-when to differentiate between base-uri() used with SAXON a…
Browse files Browse the repository at this point in the history
…nd `ldh:base-uri(.)` used with SaxonJD
  • Loading branch information
namedgraph committed Oct 9, 2023
1 parent 8a2d37c commit 54b8443
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ exclude-result-prefixes="#all"

<!-- close popup overlay (info window) -->

<xsl:template match="div[contains-token(@class, 'ol-overlay-container')]//div[contains-token(@class, 'modal-header')]/button[contains-token(@class, 'close')]" mode="ixsl:onclick" >
<xsl:template match="div[contains-token(@class, 'ol-overlay-container')]//div[contains-token(@class, 'modal-header')]/button[contains-token(@class, 'close')]" mode="ixsl:onclick">
<xsl:variable name="content-uri" select="ancestor::div[@about][1]/@about" as="xs:anyURI"/>
<xsl:variable name="container" select="ancestor::div[contains-token(@class, 'ol-overlay-container')]/div" as="element()"/>
<xsl:variable name="map" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || $content-uri || '`'), 'map')"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LIMIT 100</xsl:param>
<xsl:attribute name="class" select="concat($class, ' ', 'btn-run-query')"/>
</xsl:template>

<xsl:template name="bs2:QueryEditor" >
<xsl:template name="bs2:QueryEditor">
<xsl:param name="id" as="xs:string?"/>
<xsl:param name="class" select="'span7 main'" as="xs:string?"/>
<xsl:param name="mode" select="$ac:mode" as="xs:anyURI*"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,15 @@ exclude-result-prefixes="#all"
</xsl:message>
</xsl:function>

<!-- function stub so that Saxon-EE doesn't complain when compiling SEF -->
<xsl:function name="ldh:base-uri" as="xs:anyURI?" override-extension-function="no" cache="yes">
<xsl:param name="arg" as="node()"/>

<xsl:message use-when="system-property('xsl:product-name') = 'SAXON'" terminate="yes">
Not implemented
</xsl:message>
</xsl:function>

<!-- SHARED FUNCTIONS -->

<!-- TO-DO: move down to Web-Client -->
Expand All @@ -311,10 +320,10 @@ exclude-result-prefixes="#all"
<xsl:when test="key('resources', $this)">
<xsl:apply-templates select="key('resources', $this)" mode="ac:label"/>
</xsl:when>
<xsl:when test="$property-metadata/key('resources', $this, .)" use-when="system-property('xsl:product-name') = 'SAXON'" >
<xsl:when test="$property-metadata/key('resources', $this, .)" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:apply-templates select="$property-metadata/key('resources', $this, .)" mode="ac:label"/>
</xsl:when>
<xsl:when test="doc-available(namespace-uri()) and key('resources', $this, document(namespace-uri()))" use-when="system-property('xsl:product-name') = 'SAXON'" >
<xsl:when test="doc-available(namespace-uri()) and key('resources', $this, document(namespace-uri()))" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:apply-templates select="key('resources', $this, document(namespace-uri()))" mode="ac:label"/>
</xsl:when>
<xsl:otherwise>
Expand Down Expand Up @@ -399,9 +408,12 @@ exclude-result-prefixes="#all"
<xsl:param name="endpoint" as="xs:anyURI?" tunnel="yes"/>
<xsl:param name="query-string" select="'DESCRIBE &lt;' || . || '&gt;'" as="xs:string"/>
<xsl:param name="fragment" select="if (starts-with(., $ldt:base)) then (if (contains(., '#')) then substring-after(., '#') else ()) else encode-for-uri(.)" as="xs:string?"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(ldh:base-uri(.)), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') eq 'SaxonJS'"/>
<!-- if the URI's absolute path equals the current URL and has a #fragment, use the fragment as @id. Otherwise use encoded URI as @id. -->
<xsl:param name="id" select="if (starts-with(., '#') or (ldh:absolute-path(.) = ldh:absolute-path(base-uri()) and (contains(., '#')))) then substring-after(., '#') else (if (starts-with(., $ldt:base)) then () else encode-for-uri(.))" as="xs:string?"/>
<xsl:param name="id" select="if (starts-with(., '#') or (ldh:absolute-path(.) = ldh:absolute-path(base-uri()) and (contains(., '#')))) then substring-after(., '#') else (if (starts-with(., $ldt:base)) then () else encode-for-uri(.))" as="xs:string?" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:param name="id" select="if (starts-with(., '#') or (ldh:absolute-path(.) = ldh:absolute-path(ldh:base-uri(.)) and (contains(., '#')))) then substring-after(., '#') else (if (starts-with(., $ldt:base)) then () else encode-for-uri(.))" as="xs:string?" use-when="system-property('xsl:product-name') eq 'SaxonJS'"/>

<xsl:param name="title" select="." as="xs:string?"/>
<xsl:param name="class" as="xs:string?"/>
<xsl:param name="target" as="xs:string?"/>
Expand All @@ -419,7 +431,8 @@ exclude-result-prefixes="#all"
<xsl:param name="endpoint" as="xs:anyURI?" tunnel="yes"/>
<xsl:param name="query-string" select="'DESCRIBE &lt;' || . || '&gt;'" as="xs:string"/>
<xsl:param name="fragment" select="if (starts-with(., $ldt:base)) then (if (contains(., '#')) then substring-after(., '#') else ()) else encode-for-uri(.)" as="xs:string?"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(ldh:base-uri(.)), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') eq 'SaxonJS'"/>
<xsl:param name="id" select="$fragment" as="xs:string?"/>
<xsl:param name="label" select="if (parent::rdf:Description) then ac:svg-label(..) else ac:svg-object-label(.)" as="xs:string"/>
<xsl:param name="title" select="$label" as="xs:string"/>
Expand All @@ -443,7 +456,8 @@ exclude-result-prefixes="#all"
<xsl:param name="endpoint" as="xs:anyURI?" tunnel="yes"/>
<xsl:param name="query-string" select="'DESCRIBE &lt;' || . || '&gt;'" as="xs:string"/>
<xsl:param name="fragment" select="if (starts-with(., $ldt:base)) then (if (contains(., '#')) then substring-after(., '#') else ()) else encode-for-uri(.)" as="xs:string?"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(base-uri()), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:param name="href" select="ldh:href($ldt:base, ldh:absolute-path(ldh:base-uri(.)), map{}, if ($endpoint) then xs:anyURI($endpoint || '?query=' || encode-for-uri($query-string)) else xs:anyURI(.), $fragment)" as="xs:anyURI" use-when="system-property('xsl:product-name') eq 'SaxonJS'"/>
<xsl:param name="id" as="xs:string?"/>
<xsl:param name="title" select="." as="xs:string?"/>
<xsl:param name="class" as="xs:string?"/>
Expand Down Expand Up @@ -502,7 +516,8 @@ exclude-result-prefixes="#all"
<xsl:param name="class" select="'subject input-xxlarge'" as="xs:string?"/>
<xsl:param name="disabled" select="false()" as="xs:boolean"/>
<xsl:param name="auto" select="local-name() = 'nodeID' or starts-with(., $ldt:base)" as="xs:boolean"/>
<xsl:param name="base-uri" select="base-uri()" as="xs:anyURI" tunnel="yes"/>
<xsl:param name="base-uri" select="base-uri()" as="xs:anyURI" tunnel="yes" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:param name="base-uri" select="ldh:base-uri(.)" as="xs:anyURI" tunnel="yes" use-when="system-property('xsl:product-name') eq 'SaxonJS'"/>

<xsl:choose>
<xsl:when test="not($type = 'hidden')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ extension-element-prefixes="ixsl"
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each use-when="system-property('xsl:product-name') eq 'SaxonJS'" select=".">
<xsl:for-each select="." use-when="system-property('xsl:product-name') eq 'SaxonJS'">
<option value="{current-grouping-key()}">
<xsl:value-of select="local-name()"/>
</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ WHERE
<xsl:when test="$fragment">
<xsl:for-each select="id($fragment, ixsl:page())">
<xsl:sequence select="ixsl:call(., 'scrollIntoView', [])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each >
</xsl:for-each>
</xsl:when>
<!-- otherwise, scroll to the top of the window -->
<xsl:otherwise>
Expand Down

0 comments on commit 54b8443

Please sign in to comment.