Skip to content

Commit

Permalink
Replaced more base-uri() usages with `ldh:absolute-path(base-uri())…
Browse files Browse the repository at this point in the history
…` since it now returns the full request URL (query string included)

Debugging `ldh:base-uri(.)` in default.xsl
  • Loading branch information
namedgraph committed Oct 9, 2023
1 parent 19b92c4 commit 0a50fff
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ exclude-result-prefixes="#all">

<xsl:param name="ldh:access-to" as="xs:anyURI?"/>

<xsl:template match="rdf:RDF[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][key('resources-by-type', '&spin;ConstraintViolation') or key('resources-by-type', '&sh;ValidationResult')]" mode="xhtml:Body" priority="3">
<xsl:template match="rdf:RDF[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][key('resources-by-type', '&spin;ConstraintViolation') or key('resources-by-type', '&sh;ValidationResult')]" mode="xhtml:Body" priority="3">
<xsl:apply-templates select="." mode="bs2:RowForm">
<xsl:with-param name="action" select="base-uri($main-doc)"/>
<xsl:with-param name="action" select="ldh:absolute-path(base-uri($main-doc))"/>
<xsl:with-param name="enctype" select="()"/> <!-- don't use 'multipart/form-data' which is the default -->
<xsl:with-param name="create-resource" select="false()"/>
<xsl:with-param name="constructor-query" select="$constructor-query" tunnel="yes"/>
<xsl:with-param name="constraint-query" select="$constraint-query" tunnel="yes"/>
<xsl:with-param name="shape-query" select="$shape-query" tunnel="yes"/>
<xsl:with-param name="base-uri" select="base-uri($main-doc)" tunnel="yes"/> <!-- base-uri() is empty on constructed documents -->
<xsl:with-param name="base-uri" select="ldh:absolute-path(base-uri($main-doc))" tunnel="yes"/> <!-- base-uri() is empty on constructed documents -->
</xsl:apply-templates>
</xsl:template>

<xsl:template match="rdf:RDF[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'GET']" mode="bs2:ContentBody" priority="2">
<div about="{base-uri($main-doc)}" id="content-body" class="container-fluid">
<xsl:apply-templates select="key('resources', base-uri($main-doc))" mode="ldh:ContentList"/>
<xsl:template match="rdf:RDF[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'GET']" mode="bs2:ContentBody" priority="2">
<div about="{ldh:absolute-path(base-uri($main-doc))}" id="content-body" class="container-fluid">
<xsl:apply-templates select="key('resources', ldh:absolute-path(base-uri($main-doc)))" mode="ldh:ContentList"/>

<xsl:apply-templates select="." mode="bs2:Row"/>
</div>
</xsl:template>

<!-- currently doesn't work because the client-side does not refresh the bs2:NavBarActions -->
<!--<xsl:template match="rdf:RDF[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:NavBarActions" priority="2"/>-->
<!--<xsl:template match="rdf:RDF[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:NavBarActions" priority="2"/>-->

<xsl:template match="rdf:RDF[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:ModeTabs" priority="2"/>
<xsl:template match="rdf:RDF[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:ModeTabs" priority="2"/>

<xsl:template match="*[rdf:type/@rdf:resource = '&adm;RequestAccess'][$ac:method = 'GET']" mode="bs2:Row" priority="2">
<xsl:variable name="constructor" as="document-node()">
Expand All @@ -87,18 +87,18 @@ exclude-result-prefixes="#all">
</xsl:variable>

<xsl:apply-templates select="$constructor" mode="bs2:RowForm">
<xsl:with-param name="action" select="base-uri($main-doc)"/>
<xsl:with-param name="action" select="ldh:absolute-path(base-uri($main-doc))"/>
<xsl:with-param name="enctype" select="()"/> <!-- don't use 'multipart/form-data' which is the default -->
<xsl:with-param name="create-resource" select="false()"/>
<xsl:with-param name="constructor-query" select="$constructor-query" tunnel="yes"/>
<xsl:with-param name="constraint-query" select="$constraint-query" tunnel="yes"/>
<xsl:with-param name="shape-query" select="$shape-query" tunnel="yes"/>
<xsl:with-param name="base-uri" select="base-uri($main-doc)" tunnel="yes"/> <!-- base-uri() is empty on constructed documents -->
<xsl:with-param name="base-uri" select="ldh:absolute-path(base-uri($main-doc))" tunnel="yes"/> <!-- base-uri() is empty on constructed documents -->
</xsl:apply-templates>
</xsl:template>

<!-- display stored AuthorizationRequest data after successful POST (without ConstraintViolations) -->
<xsl:template match="rdf:RDF[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))][1]" mode="bs2:Row" priority="3">
<xsl:template match="rdf:RDF[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))][1]" mode="bs2:Row" priority="3">
<xsl:param name="id" as="xs:string?"/>
<xsl:param name="class" select="'offset2 span7'" as="xs:string?"/>

Expand All @@ -118,12 +118,12 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- suppress other resources -->
<xsl:template match="*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))]" mode="bs2:Row" priority="2"/>
<xsl:template match="*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))]" mode="bs2:Row" priority="2"/>

<!-- hide object blank nodes (that only have a single rdf:type property) from constructed models -->
<xsl:template match="rdf:Description[$ac:method = 'GET'][@rdf:nodeID][not(rdf:type/@rdf:resource = ('&lacl;AuthorizationRequest', '&dh;Item'))][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:RowForm" priority="3"/>
<xsl:template match="rdf:Description[$ac:method = 'GET'][@rdf:nodeID][not(rdf:type/@rdf:resource = ('&lacl;AuthorizationRequest', '&dh;Item'))][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:RowForm" priority="3"/>

<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="1">
<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="1">
<xsl:next-match>
<xsl:with-param name="show-subject" select="false()" tunnel="yes"/>
<xsl:with-param name="legend" select="false()"/>
Expand All @@ -132,13 +132,13 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- make properties required -->
<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/*" mode="bs2:FormControl" priority="1">
<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/*" mode="bs2:FormControl" priority="1">
<xsl:next-match>
<xsl:with-param name="required" select="true()"/>
</xsl:next-match>
</xsl:template>

<xsl:template match="*[@rdf:about or @rdf:nodeID][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/sioc:has_parent | *[@rdf:about or @rdf:nodeID][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/sioc:has_container" mode="bs2:FormControl" priority="4">
<xsl:template match="*[@rdf:about or @rdf:nodeID][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/sioc:has_parent | *[@rdf:about or @rdf:nodeID][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/sioc:has_container" mode="bs2:FormControl" priority="4">
<xsl:apply-templates select="." mode="xhtml:Input">
<xsl:with-param name="type" select="'hidden'"/>
</xsl:apply-templates>
Expand All @@ -161,7 +161,7 @@ exclude-result-prefixes="#all">
</xsl:call-template>
</xsl:template>

<xsl:template match="lacl:requestMode/@rdf:*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:template match="lacl:requestMode/@rdf:*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:param name="id" select="generate-id()" as="xs:string"/>
<xsl:param name="class" as="xs:string?"/>
<xsl:param name="disabled" select="false()" as="xs:boolean"/>
Expand All @@ -185,7 +185,7 @@ exclude-result-prefixes="#all">
</xsl:if>
</xsl:template>

<xsl:template match="lacl:requestAgent[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:template match="lacl:requestAgent[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:apply-templates select="." mode="xhtml:Input">
<xsl:with-param name="type" select="'hidden'"/>
</xsl:apply-templates>
Expand All @@ -209,7 +209,7 @@ exclude-result-prefixes="#all">
</xsl:call-template>
</xsl:template>

<xsl:template match="lacl:requestAccessTo/@rdf:*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ldh:access-to]" mode="bs2:FormControl" priority="2">
<xsl:template match="lacl:requestAccessTo/@rdf:*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')][$ldh:access-to]" mode="bs2:FormControl" priority="2">
<select name="ou" id="{generate-id()}" multiple="multiple" size="4">
<option value="{resolve-uri('../add', $ldt:base)}" selected="selected">Add RDF endpoint</option>
<option value="{resolve-uri('../service', $ldt:base)}" selected="selected">Graph Store endpoint</option>
Expand All @@ -219,7 +219,7 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- show first property as a select -->
<xsl:template match="lacl:requestAccessToClass[1]/@rdf:*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:template match="lacl:requestAccessToClass[1]/@rdf:*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="2">
<xsl:variable name="this" select="../concat(namespace-uri(), local-name())" as="xs:string"/>
<xsl:variable name="classes" select="key('resources', ('&def;Root', '&dh;Container','&dh;Item', '&nfo;FileDataObject'), document(ac:document-uri('&def;')))" as="element()*"/>
<select name="ou" id="{generate-id()}" multiple="multiple" size="{count($classes)}">
Expand All @@ -233,20 +233,20 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- hide following properties -->
<xsl:template match="lacl:requestAccessToClass/@rdf:*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="1"/>
<xsl:template match="lacl:requestAccessToClass/@rdf:*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="1"/>

<!-- hide type control -->
<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:TypeControl" priority="2">
<xsl:template match="*[*][@rdf:about or @rdf:nodeID][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:TypeControl" priority="2">
<xsl:next-match>
<xsl:with-param name="hidden" select="true()"/>
</xsl:next-match>
</xsl:template>

<!-- suppress properties -->
<xsl:template match="dct:title[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | dct:description[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | rdf:_1[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="4"/>
<xsl:template match="dct:title[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | dct:description[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | rdf:_1[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:FormControl" priority="4"/>

<!-- hide properties (including all of document resource properties) -->
<xsl:template match="rdfs:label[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | foaf:isPrimaryTopicOf[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | *[foaf:primaryTopic][(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/*" mode="bs2:FormControl" priority="3">
<xsl:template match="rdfs:label[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | foaf:isPrimaryTopicOf[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')] | *[foaf:primaryTopic][(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]/*" mode="bs2:FormControl" priority="3">
<xsl:apply-templates select="." mode="xhtml:Input">
<xsl:with-param name="type" select="'hidden'"/>
</xsl:apply-templates>
Expand All @@ -259,6 +259,6 @@ exclude-result-prefixes="#all">
</xsl:template>

<!-- turn off additional properties - it applies on the constructor document and not the $main-doc -->
<xsl:template match="*[(key('resources', base-uri($main-doc), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:PropertyControl" priority="1"/>
<xsl:template match="*[(key('resources', ldh:absolute-path(base-uri($main-doc)), $main-doc)/rdf:type/@rdf:resource = '&adm;RequestAccess')]" mode="bs2:PropertyControl" priority="1"/>

</xsl:stylesheet>
Loading

0 comments on commit 0a50fff

Please sign in to comment.