Skip to content

Commit

Permalink
ldh:base-uri strips fragment
Browse files Browse the repository at this point in the history
Replaced `ac:uri()` with `ldh:base-uri(.)`
Removed `ac:uri` function
  • Loading branch information
namedgraph committed Oct 8, 2023
1 parent 693f6df commit cf9afcb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,10 @@ exclude-result-prefixes="#all"
<!-- updating existing content -->
<xsl:when test="$container/@about">
<xsl:variable name="content-uri" select="$container/@about" as="xs:anyURI"/>
<xsl:variable name="update-string" select="replace($content-update-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-update-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$content', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$newValue', '&quot;' || $content-string || '&quot;^^&lt;&rdf;XMLLiteral&gt;', 'q')" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onXHTMLContentUpdate">
Expand All @@ -587,14 +587,14 @@ exclude-result-prefixes="#all"
<!-- appending new content -->
<xsl:otherwise>
<xsl:variable name="content-id" select="'id' || ac:uuid()" as="xs:string"/>
<xsl:variable name="content-uri" select="xs:anyURI(ac:uri() || '#' || $content-id)" as="xs:anyURI"/> <!-- build content URI -->
<xsl:variable name="content-uri" select="xs:anyURI(ldh:base-uri(.) || '#' || $content-id)" as="xs:anyURI"/> <!-- build content URI -->
<ixsl:set-attribute name="id" select="$content-id" object="$container"/>
<ixsl:set-attribute name="about" select="$content-uri" object="$container"/>

<xsl:variable name="update-string" select="replace($content-append-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-append-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$content', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$value', '&quot;' || $content-string || '&quot;^^&lt;&rdf;XMLLiteral&gt;', 'q')" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onXHTMLContentUpdate">
Expand Down Expand Up @@ -628,16 +628,16 @@ exclude-result-prefixes="#all"
<!-- updating existing content -->
<xsl:when test="$container/@about">
<xsl:variable name="content-uri" select="$container/@about" as="xs:anyURI"/>
<xsl:variable name="update-string" select="replace($content-update-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-update-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$content', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$newValue', '&lt;' || $content-value || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="if ($mode) then replace($update-string, '$newMode', '&lt;' || $mode || '&gt;', 'q') else $update-string" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onResourceContentUpdate">
<xsl:with-param name="container" select="$container"/>
<xsl:with-param name="uri" select="ac:uri()"/>
<xsl:with-param name="uri" select="ldh:base-uri(.)"/>
<xsl:with-param name="content-value" select="$content-value"/>
<xsl:with-param name="mode" select="$mode"/>
</xsl:call-template>
Expand All @@ -648,20 +648,20 @@ exclude-result-prefixes="#all"
<!-- appending new content -->
<xsl:otherwise>
<xsl:variable name="content-id" select="'id' || ac:uuid()" as="xs:string"/>
<xsl:variable name="content-uri" select="xs:anyURI(ac:uri() || '#' || $content-id)" as="xs:anyURI"/> <!-- build content URI -->
<xsl:variable name="content-uri" select="xs:anyURI(ldh:base-uri(.) || '#' || $content-id)" as="xs:anyURI"/> <!-- build content URI -->
<ixsl:set-attribute name="id" select="$content-id" object="$container"/>
<ixsl:set-attribute name="about" select="$content-uri" object="$container"/>

<xsl:variable name="update-string" select="replace($content-append-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-append-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$content', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$value', '&lt;' || $content-value || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="if ($mode) then replace($update-string, '$mode', '&lt;' || $mode || '&gt;', 'q') else $update-string" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onResourceContentUpdate">
<xsl:with-param name="container" select="$container"/>
<xsl:with-param name="uri" select="ac:uri()"/>
<xsl:with-param name="uri" select="ldh:base-uri(.)"/>
<xsl:with-param name="content-value" select="$content-value"/>
<xsl:with-param name="mode" select="$mode"/>
</xsl:call-template>
Expand All @@ -686,9 +686,9 @@ exclude-result-prefixes="#all"
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>

<xsl:variable name="content-uri" select="$container/@about" as="xs:anyURI"/>
<xsl:variable name="update-string" select="replace($content-delete-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-delete-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$content', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onContentDelete">
Expand Down Expand Up @@ -748,9 +748,7 @@ exclude-result-prefixes="#all"
<!-- updating existing content -->
<xsl:when test="$container/@about">
<xsl:for-each select="$container">
<xsl:call-template name="ldh:LoadContent">
<!-- <xsl:with-param name="uri" select="ac:uri()"/> content value gets read from dataset.contentValue -->
</xsl:call-template>
<xsl:call-template name="ldh:LoadContent"/>
</xsl:for-each>
</xsl:when>
<!-- remove content that hasn't been saved yet -->
Expand Down Expand Up @@ -1010,10 +1008,10 @@ exclude-result-prefixes="#all"
<xsl:variable name="drop-content" select="key('content-by-about', $drop-content-uri)" as="element()"/>
<xsl:sequence select="ixsl:call(., 'after', [ $drop-content ])"/>

<xsl:variable name="update-string" select="replace($content-swap-string, '$this', '&lt;' || ac:uri() || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($content-swap-string, '$this', '&lt;' || ldh:base-uri(.) || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$targetContent', '&lt;' || $content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="update-string" select="replace($update-string, '$sourceContent', '&lt;' || $drop-content-uri || '&gt;', 'q')" as="xs:string"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ac:uri())" as="xs:anyURI"/>
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ldh:absolute-path(ldh:href()), map{}, ldh:base-uri(.))" as="xs:anyURI"/>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string }">
<xsl:call-template name="onContentSwap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ exclude-result-prefixes="#all"
<xsl:sequence select="xs:anyURI(ixsl:get(ixsl:window(), 'LinkedDataHub.base'))"/>
</xsl:function>

<!-- TO-DO: replace with standard XPath `base-uri` after this is fixed: -->
<!-- TO-DO: replace with standard XPath `base-uri` after this is fixed: https://saxonica.plan.io/issues/6216 -->
<xsl:function name="ldh:base-uri" as="xs:anyURI?">
<xsl:param name="arg" as="node()"/>

<xsl:sequence select="if (ixsl:contains($arg, 'baseURI')) then ixsl:get($arg, 'baseURI') else ()"/>
<xsl:sequence select="if (ixsl:contains($arg, 'baseURI')) then ac:document-uri(ixsl:get($arg, 'baseURI')) else ()"/>
</xsl:function>

<xsl:function name="ac:uri" as="xs:anyURI">
<!-- <xsl:function name="ac:uri" as="xs:anyURI">
<xsl:sequence select="xs:anyURI(ixsl:get(ixsl:window(), 'LinkedDataHub.uri'))"/>
</xsl:function>
</xsl:function>-->

<xsl:function name="ac:mode" as="xs:anyURI*">
<xsl:variable name="href" select="ldh:href()" as="xs:anyURI"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ LIMIT 100</xsl:param>
</xsl:if>

<fieldset>
<!-- <label for="query-uri">Query</label>
<xsl:text> </xsl:text>
<select id="query-uri" name="query-uri" class="input-xxlarge">
<option value="">[Query]</option>
</select>-->

<label for="service">Service</label>
<xsl:text> </xsl:text>
<select id="query-service" name="service" class="input-xxlarge">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ exclude-result-prefixes="#all">
<xsl:param name="force-exclude-all-namespaces" select="true()"/>
<xsl:param name="ac:httpHeaders" as="xs:string"/>
<xsl:param name="ac:method" as="xs:string"/>
<xsl:param name="ac:uri" as="xs:anyURI"/>
<!-- <xsl:param name="ac:uri" as="xs:anyURI"/>-->
<xsl:param name="ac:mode" as="xs:anyURI*"/> <!-- select="xs:anyURI('&ac;ReadMode')" -->
<xsl:param name="acl:mode" as="xs:anyURI*"/>
<xsl:param name="ldh:forShape" as="xs:anyURI?"/>
Expand Down Expand Up @@ -239,9 +239,9 @@ LIMIT 100
<rdf:Description rdf:about="">
</rdf:Description>

<xsl:function name="ac:uri" as="xs:anyURI">
<!-- <xsl:function name="ac:uri" as="xs:anyURI">
<xsl:sequence select="$ac:uri"/>
</xsl:function>
</xsl:function>-->

<xsl:function name="ldh:href" as="xs:anyURI">
<xsl:sequence select="$ldh:requestUri"/>
Expand Down
Loading

0 comments on commit cf9afcb

Please sign in to comment.