Skip to content

Commit 931f821

Browse files
namedgraphclaude
andcommitted
Hoist dataset (FROM) clause when wrapping a query into DESCRIBE
ldh:wrap-describe nested the original query — including its FROM / FROM NAMED dataset clause — as a subquery inside DESCRIBE * WHERE { … }. A dataset clause is only legal on the outermost query, so any view query carrying a FROM (e.g. FROM <urn:x-arq:UnionGraph>) became an invalid subquery and the SPARQL endpoint returned 400. Result-set views (ldh:View, all modes) always go through ldh:RenderView → ldh:wrap-describe, so they all broke; charts (ResultSetChart) bypass this path, which is why FROM works there. Hoist the dataset clause up to the wrapping DESCRIBE and strip it from the nested subquery. No-op for queries without a dataset clause, so fully backwards-compatible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6aef905 commit 931f821

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,28 @@ extension-element-prefixes="ixsl"
104104
<json:array key="variables">
105105
<json:string>*</json:string>
106106
</json:array>
107+
<!-- Hoist the dataset (FROM / FROM NAMED) clause up to the wrapping DESCRIBE.
108+
A dataset clause is only legal on the outermost query, so it cannot remain
109+
on the SELECT once that becomes a subquery (otherwise: SPARQL parse error).
110+
No-op for queries without a dataset clause, so fully backwards-compatible. -->
111+
<xsl:copy-of select="json:map[@key = 'from']"/>
107112
<json:array key="where">
108-
<xsl:sequence select="."/>
113+
<xsl:apply-templates select="." mode="ldh:strip-from"/>
109114
</json:array>
110115
</json:map>
111116
</xsl:template>
112117

118+
<!-- strip the (now hoisted) top-level dataset clause off the nested subquery -->
119+
120+
<!-- identity transform -->
121+
<xsl:template match="@* | node()" mode="ldh:strip-from">
122+
<xsl:copy>
123+
<xsl:apply-templates select="@* | node()" mode="#current"/>
124+
</xsl:copy>
125+
</xsl:template>
126+
127+
<xsl:template match="/json:map/json:map[@key = 'from']" mode="ldh:strip-from" priority="1"/>
128+
113129
<!-- add parallax step -->
114130

115131
<!-- identity transform -->

0 commit comments

Comments
 (0)