Skip to content

Commit 0b44cb7

Browse files
committed
Handle empty resource
1 parent 4c3dd28 commit 0b44cb7

1 file changed

Lines changed: 30 additions & 17 deletions

File tree

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

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,38 @@ exclude-result-prefixes="#all"
103103

104104
<xsl:for-each select="?body">
105105
<xsl:variable name="resource" select="key('resources', $resource-uri)" as="element()?"/>
106-
<xsl:variable name="object-uris" select="distinct-values($resource/*/@rdf:resource[not(key('resources', ., root($resource)))])" as="xs:string*"/>
107-
<xsl:variable name="query-string" select="$object-metadata-query || ' VALUES $this { ' || string-join(for $uri in $object-uris return '&lt;' || $uri || '&gt;', ' ') || ' }'" as="xs:string"/>
108-
<xsl:variable name="request" as="item()*">
109-
<ixsl:schedule-action http-request="map{ 'method': 'POST', 'href': sd:endpoint(), 'media-type': 'application/sparql-query', 'body': $query-string, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
110-
<xsl:call-template name="ldh:LoadBlockObjectMetadata">
111-
<xsl:with-param name="block" select="$block"/>
112-
<xsl:with-param name="container" select="$container"/>
113-
<xsl:with-param name="resource" select="$resource"/>
114-
<xsl:with-param name="graph" select="$graph"/>
115-
<xsl:with-param name="mode" select="$mode"/>
116-
<xsl:with-param name="show-edit-button" select="$show-edit-button"/>
117-
</xsl:call-template>
118-
</ixsl:schedule-action>
119-
</xsl:variable>
120-
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
106+
<xsl:choose>
107+
<xsl:when test="$resource">
108+
<xsl:variable name="object-uris" select="distinct-values($resource/*/@rdf:resource[not(key('resources', ., root($resource)))])" as="xs:string*"/>
109+
<xsl:variable name="query-string" select="$object-metadata-query || ' VALUES $this { ' || string-join(for $uri in $object-uris return '&lt;' || $uri || '&gt;', ' ') || ' }'" as="xs:string"/>
110+
<xsl:variable name="request" as="item()*">
111+
<ixsl:schedule-action http-request="map{ 'method': 'POST', 'href': sd:endpoint(), 'media-type': 'application/sparql-query', 'body': $query-string, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
112+
<xsl:call-template name="ldh:LoadBlockObjectMetadata">
113+
<xsl:with-param name="block" select="$block"/>
114+
<xsl:with-param name="container" select="$container"/>
115+
<xsl:with-param name="resource" select="$resource"/>
116+
<xsl:with-param name="graph" select="$graph"/>
117+
<xsl:with-param name="mode" select="$mode"/>
118+
<xsl:with-param name="show-edit-button" select="$show-edit-button"/>
119+
</xsl:call-template>
120+
</ixsl:schedule-action>
121+
</xsl:variable>
122+
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
123+
</xsl:when>
124+
<xsl:otherwise>
125+
<xsl:for-each select="$container">
126+
<xsl:result-document href="?." method="ixsl:replace-content">
127+
<div class="alert alert-block">
128+
<strong>Document loaded successfully but resource was not found: <a href="{$resource-uri}"><xsl:value-of select="$resource-uri"/></a></strong>
129+
</div>
130+
</xsl:result-document>
131+
</xsl:for-each>
132+
</xsl:otherwise>
133+
</xsl:choose>
121134
</xsl:for-each>
122135
</xsl:when>
123136
<xsl:when test="?status = 406">
124-
<xsl:for-each select="$container//div[contains-token(@class, 'main')]">
137+
<xsl:for-each select="$container">
125138
<xsl:result-document href="?." method="ixsl:replace-content">
126139
<div class="offset2 span7 main">
127140
<object data="{$resource-uri}"/>
@@ -130,7 +143,7 @@ exclude-result-prefixes="#all"
130143
</xsl:for-each>
131144
</xsl:when>
132145
<xsl:otherwise>
133-
<xsl:for-each select="$container//div[contains-token(@class, 'main')]">
146+
<xsl:for-each select="$container">
134147
<xsl:result-document href="?." method="ixsl:replace-content">
135148
<div class="alert alert-block">
136149
<strong>Could not load resource: <a href="{$resource-uri}"><xsl:value-of select="$resource-uri"/></a></strong>

0 commit comments

Comments
 (0)