Skip to content

Commit ecc4292

Browse files
namedgraphclaude
andcommitted
Do not append facet well into left-nav when there are no BGP triples
The ldh:RenderFacets named template was unconditionally appending a div.well.well-small into div.left-nav even when the SPARQL query had no qualifying BGP triples, causing an empty grey box to appear. The fix moves bgp-triples-map computation before the guard and conditions the append on exists($bgp-triples-map), leaving the server-rendered empty div.left-nav unstyled when there are no facets to show. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2c82919 commit ecc4292

File tree

1 file changed

+7
-6
lines changed
  • src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,18 @@ exclude-result-prefixes="#all"
887887
<!-- use the first SELECT variable as the facet variable name (so that we do not generate facets based on other variables) -->
888888
<xsl:variable name="initial-var-name" select="$select-xml/json:map/json:array[@key = 'variables']/json:string[1]/substring-after(., '?')" as="xs:string"/>
889889

890-
<!-- only append facets if they are not already present -->
891-
<xsl:if test="not(id($sub-container-id, ixsl:page()))">
890+
<!-- use the BGPs where the predicate is a URI value and the subject and object are variables -->
891+
<xsl:variable name="bgp-triples-map" select="$select-xml//json:map[json:string[@key = 'type'] = 'bgp']/json:array[@key = 'triples']/json:map[json:string[@key = 'subject'] = '?' || $initial-var-name][not(starts-with(json:string[@key = 'predicate'], '?'))][starts-with(json:string[@key = 'object'], '?')]" as="element()*"/>
892+
893+
<!-- only append facets if they are not already present and there are BGP triples to facet on -->
894+
<xsl:if test="not(id($sub-container-id, ixsl:page())) and exists($bgp-triples-map)">
892895
<xsl:result-document href="?." method="ixsl:append-content">
893896
<xsl:apply-templates select="." mode="ldh:RenderFacets">
894897
<xsl:with-param name="id" select="$sub-container-id"/>
895898
</xsl:apply-templates>
896899
</xsl:result-document>
897-
900+
898901
<xsl:variable name="sub-container" select="id($sub-container-id, ixsl:page())" as="element()"/>
899-
<!-- use the BGPs where the predicate is a URI value and the subject and object are variables -->
900-
<xsl:variable name="bgp-triples-map" select="$select-xml//json:map[json:string[@key = 'type'] = 'bgp']/json:array[@key = 'triples']/json:map[json:string[@key = 'subject'] = '?' || $initial-var-name][not(starts-with(json:string[@key = 'predicate'], '?'))][starts-with(json:string[@key = 'object'], '?')]" as="element()*"/>
901902

902903
<xsl:for-each select="$bgp-triples-map">
903904
<!-- only simple properties in the BGP are supported, not property paths etc. -->
@@ -917,7 +918,7 @@ exclude-result-prefixes="#all"
917918
'object-var-name': $object-var-name
918919
}"/>
919920
<ixsl:promise select="ixsl:http-request($context('request')) =>
920-
ixsl:then(ldh:rethread-response($context, ?)) =>
921+
ixsl:then(ldh:rethread-response($context, ?)) =>
921922
ixsl:then(ldh:handle-response#1) =>
922923
ixsl:then(ldh:facet-filter-response#1)"
923924
on-failure="ldh:promise-failure#1"/>

0 commit comments

Comments
 (0)