Skip to content

Commit be7c4eb

Browse files
namedgraphclaude
andcommitted
Mode-isolate normalize-rdfxml so it stops intercepting default-mode dispatches
normalize-rdfxml.xsl declared its entry-point template as match="/" with no mode, which sat in the unnamed mode globally and caught every <xsl:apply-templates> against a document-node — including the otherwise branch of ldh:ViewModeChoice that handles ReadMode for views. The four normalisation passes ran and emitted raw rdf:Description markup into the HTML result tree, so ReadMode rendered the text content of literals with no structure. Scope the entry-point and the first-pass templates to a named mode (ldh:normalize-rdfxml), rename the second pass to ldh:flatten-rdfxml for consistency, and update the only call site (graph3d.xsl) to enter the mode explicitly. Same-mode recursion inside the entry-point uses mode="#current". Also drop the redundant view.xsl client-side rdf:RDF default-mode template flagged with the "align with SSR" TO-DO — it shadowed nothing once normalize-rdfxml stopped leaking and was never reached in practice. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent daa15c5 commit be7c4eb

3 files changed

Lines changed: 19 additions & 28 deletions

File tree

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ exclude-result-prefixes="#all"
711711
<xsl:param name="results" as="document-node()"/>
712712
<xsl:param name="object-metadata" as="document-node()?"/>
713713
<xsl:param name="active-mode" as="xs:anyURI"/>
714-
714+
715715
<xsl:choose>
716716
<xsl:when test="$active-mode = '&ac;ListMode'">
717717
<xsl:apply-templates select="$results" mode="bs2:ContainerBlockList">
@@ -959,16 +959,7 @@ exclude-result-prefixes="#all"
959959
</xsl:if>
960960
</div>
961961
</xsl:template>
962-
963-
<!-- DEFAULT -->
964-
965-
<!-- TO-DO: align with SSR rdf:RDF mode -->
966-
<xsl:template match="rdf:RDF">
967-
<xsl:apply-templates>
968-
<xsl:sort select="ac:label(.)"/>
969-
</xsl:apply-templates>
970-
</xsl:template>
971-
962+
972963
<!-- block list -->
973964

974965
<xsl:template match="rdf:RDF" mode="bs2:ContainerBlockList" use-when="system-property('xsl:product-name') eq 'SaxonJS'">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ exclude-result-prefixes="#all"
267267
<xsl:for-each select="$response?body">
268268
<xsl:variable name="base-uri" select="if (contains($document-uri, '#')) then xs:anyURI(substring-before($document-uri, '#')) else $document-uri" as="xs:anyURI"/>
269269
<xsl:variable name="normalized-rdf" as="document-node()">
270-
<xsl:apply-templates select=".">
270+
<xsl:apply-templates select="." mode="ldh:normalize-rdfxml">
271271
<xsl:with-param name="base-uri" select="$base-uri"/>
272272
</xsl:apply-templates>
273273
</xsl:variable>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/normalize-rdfxml.xsl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
version="3.0">
99

1010
<!-- Main template - apply three-pass normalization -->
11-
<xsl:template match="/">
11+
<xsl:template match="/" mode="ldh:normalize-rdfxml">
1212
<xsl:param name="base-uri" select="base-uri(.)" as="xs:anyURI"/>
1313

1414
<!-- First pass: normalize RDF/XML to canonical form -->
1515
<xsl:variable name="normalized-rdf" as="document-node()">
1616
<xsl:document>
17-
<xsl:apply-templates select="rdf:RDF" mode="ldh:normalize-RDF"/>
17+
<xsl:apply-templates select="rdf:RDF" mode="#current"/>
1818
</xsl:document>
1919
</xsl:variable>
2020

2121
<!-- Second pass: flatten all nested rdf:Description to top level -->
2222
<xsl:variable name="flattened-rdf" as="document-node()">
2323
<xsl:document>
24-
<xsl:apply-templates select="$normalized-rdf/rdf:RDF" mode="ldh:flatten-RDF"/>
24+
<xsl:apply-templates select="$normalized-rdf/rdf:RDF" mode="ldh:flatten-rdfxml"/>
2525
</xsl:document>
2626
</xsl:variable>
2727

@@ -67,7 +67,7 @@
6767
======================================== -->
6868

6969
<!-- Copy rdf:RDF root element -->
70-
<xsl:template match="rdf:RDF" mode="ldh:normalize-RDF">
70+
<xsl:template match="rdf:RDF" mode="ldh:normalize-rdfxml">
7171
<xsl:copy>
7272
<xsl:copy-of select="@*"/>
7373
<xsl:apply-templates mode="#current"/>
@@ -76,7 +76,7 @@
7676

7777
<!-- Normalize typed nodes (e.g., <foaf:Person>) to rdf:Description with explicit rdf:type -->
7878
<!-- Also handles rdf:ID attribute -->
79-
<xsl:template match="rdf:RDF/*[@rdf:about or @rdf:nodeID or @rdf:ID][not(self::rdf:Description)]" mode="ldh:normalize-RDF">
79+
<xsl:template match="rdf:RDF/*[@rdf:about or @rdf:nodeID or @rdf:ID][not(self::rdf:Description)]" mode="ldh:normalize-rdfxml">
8080
<rdf:Description>
8181
<!-- Convert rdf:ID to rdf:about with fragment -->
8282
<xsl:choose>
@@ -103,7 +103,7 @@
103103

104104
<!-- Already-normalized rdf:Description nodes - expand property attributes -->
105105
<!-- Also handles rdf:ID attribute -->
106-
<xsl:template match="rdf:Description[@rdf:about or @rdf:nodeID or @rdf:ID]" mode="ldh:normalize-RDF">
106+
<xsl:template match="rdf:Description[@rdf:about or @rdf:nodeID or @rdf:ID]" mode="ldh:normalize-rdfxml">
107107
<xsl:copy>
108108
<!-- Convert rdf:ID to rdf:about with fragment -->
109109
<xsl:choose>
@@ -127,7 +127,7 @@
127127
</xsl:template>
128128

129129
<!-- Normalize rdf:parseType="Literal" - keep as-is since it's already canonical -->
130-
<xsl:template match="*[@rdf:parseType = 'Literal']" mode="ldh:normalize-RDF">
130+
<xsl:template match="*[@rdf:parseType = 'Literal']" mode="ldh:normalize-rdfxml">
131131
<xsl:copy>
132132
<xsl:copy-of select="@rdf:parseType"/>
133133
<!-- Copy the XML content as-is -->
@@ -136,7 +136,7 @@
136136
</xsl:template>
137137

138138
<!-- Normalize rdf:parseType="Collection" - create RDF list structure -->
139-
<xsl:template match="*[@rdf:parseType = 'Collection']" mode="ldh:normalize-RDF">
139+
<xsl:template match="*[@rdf:parseType = 'Collection']" mode="ldh:normalize-rdfxml">
140140
<xsl:choose>
141141
<!-- Empty collection -->
142142
<xsl:when test="not(*)">
@@ -222,7 +222,7 @@
222222
</xsl:template>
223223

224224
<!-- Normalize rdf:parseType="Resource" - create nested blank node that will be flattened later -->
225-
<xsl:template match="*[@rdf:parseType = 'Resource']" mode="ldh:normalize-RDF">
225+
<xsl:template match="*[@rdf:parseType = 'Resource']" mode="ldh:normalize-rdfxml">
226226
<xsl:variable name="blank-node-id" select="concat('b', generate-id())"/>
227227

228228
<!-- Create property element with nested blank node rdf:Description -->
@@ -234,14 +234,14 @@
234234
</xsl:template>
235235

236236
<!-- Copy property elements that have rdf:resource or rdf:nodeID (object references) -->
237-
<xsl:template match="rdf:Description/*[@rdf:resource or @rdf:nodeID]" mode="ldh:normalize-RDF">
237+
<xsl:template match="rdf:Description/*[@rdf:resource or @rdf:nodeID]" mode="ldh:normalize-rdfxml">
238238
<xsl:copy>
239239
<xsl:copy-of select="@rdf:resource | @rdf:nodeID"/>
240240
</xsl:copy>
241241
</xsl:template>
242242

243243
<!-- Handle RDF containers (Bag, Seq, Alt) -->
244-
<xsl:template match="rdf:Bag | rdf:Seq | rdf:Alt" mode="ldh:normalize-RDF" priority="1">
244+
<xsl:template match="rdf:Bag | rdf:Seq | rdf:Alt" mode="ldh:normalize-rdfxml" priority="1">
245245
<rdf:Description>
246246
<xsl:copy-of select="@rdf:about | @rdf:nodeID"/>
247247
<xsl:if test="not(@rdf:about or @rdf:nodeID)">
@@ -253,15 +253,15 @@
253253
</xsl:template>
254254

255255
<!-- Suppress default text node copying for containers -->
256-
<xsl:template match="rdf:Bag/text() | rdf:Seq/text() | rdf:Alt/text()" mode="ldh:normalize-RDF">
256+
<xsl:template match="rdf:Bag/text() | rdf:Seq/text() | rdf:Alt/text()" mode="ldh:normalize-rdfxml">
257257
<!-- Ignore whitespace text nodes in containers -->
258258
<xsl:if test="normalize-space(.) != ''">
259259
<xsl:value-of select="."/>
260260
</xsl:if>
261261
</xsl:template>
262262

263263
<!-- Expand rdf:li to rdf:_N based on position -->
264-
<xsl:template match="rdf:li" mode="ldh:normalize-RDF">
264+
<xsl:template match="rdf:li" mode="ldh:normalize-rdfxml">
265265
<xsl:variable name="position" select="count(preceding-sibling::rdf:li) + 1" as="xs:integer"/>
266266
<xsl:element name="rdf:_{$position}" namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
267267
<xsl:copy-of select="@rdf:resource | @rdf:nodeID | @rdf:datatype | @xml:lang"/>
@@ -277,7 +277,7 @@
277277
<!-- Copy property elements with literal values or datatype -->
278278
<!-- Preserve xml:lang attribute -->
279279
<!-- Only match properties with text content, not element children -->
280-
<xsl:template match="rdf:Description/*[not(@rdf:resource) and not(@rdf:nodeID) and not(@rdf:parseType) and not(*)]" mode="ldh:normalize-RDF">
280+
<xsl:template match="rdf:Description/*[not(@rdf:resource) and not(@rdf:nodeID) and not(@rdf:parseType) and not(*)]" mode="ldh:normalize-rdfxml">
281281
<xsl:copy>
282282
<xsl:copy-of select="@rdf:datatype | @xml:lang"/>
283283
<xsl:value-of select="."/>
@@ -286,7 +286,7 @@
286286

287287
<!-- Generic template to handle any property element that doesn't match more specific templates -->
288288
<!-- This catches property elements from rdf:parseType="Resource" content and rdf:li -->
289-
<xsl:template match="*[not(self::rdf:RDF) and not(self::rdf:Description) and not(self::rdf:li) and not(self::rdf:Bag) and not(self::rdf:Seq) and not(self::rdf:Alt)]" mode="ldh:normalize-RDF" priority="-1">
289+
<xsl:template match="*[not(self::rdf:RDF) and not(self::rdf:Description) and not(self::rdf:li) and not(self::rdf:Bag) and not(self::rdf:Seq) and not(self::rdf:Alt)]" mode="ldh:normalize-rdfxml" priority="-1">
290290
<xsl:choose>
291291
<!-- Property with rdf:resource or rdf:nodeID -->
292292
<xsl:when test="@rdf:resource or @rdf:nodeID">
@@ -347,7 +347,7 @@
347347
======================================== -->
348348

349349
<!-- Collect all rdf:Description elements at any level and make them direct children of rdf:RDF -->
350-
<xsl:template match="rdf:RDF" mode="ldh:flatten-RDF">
350+
<xsl:template match="rdf:RDF" mode="ldh:flatten-rdfxml">
351351
<xsl:copy>
352352
<xsl:copy-of select="@*"/>
353353
<!-- Process all rdf:Description elements (top-level and nested) -->

0 commit comments

Comments
 (0)