Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit e6b8451

Browse files
authored
Merge pull request #537 from grtjn/528-indent-xsl
Fixed #528: solved endless loop, updated some more
2 parents 7d61d03 + 6de0d00 commit e6b8451

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

app/templates/rest-api/transforms/indent.xsl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
REST transform for returning XML with indentation for the purpose of showing it to the end user.
44
-->
55
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6+
xmlns:map="http://marklogic.com/xdmp/map"
7+
xmlns:util="http://marklogic.com/utilities"
8+
xmlns:xdmp="http://marklogic.com/xdmp"
9+
10+
extension-element-prefixes="xdmp"
611
exclude-result-prefixes="#all">
712

13+
<xdmp:import-module namespace="http://marklogic.com/utilities" href="/lib/utilities.xqy"/>
14+
15+
<xsl:param name="context" as="map:map"/>
16+
<xsl:param name="params" as="map:map"/>
17+
818
<xsl:output indent="yes" omit-xml-declaration="yes"/>
919
<xsl:strip-space elements="*"/>
1020

@@ -15,7 +25,17 @@ REST transform for returning XML with indentation for the purpose of showing it
1525
</xsl:template>
1626

1727
<xsl:template match="/">
18-
<xsl:apply-templates select="."/>
28+
<xsl:variable name="uri" select="map:get($context, 'uri')"/>
29+
<xsl:variable name="content-type" select="util:get-content-type($uri, /)" />
30+
<xsl:sequence select="map:put($context, 'output-type', $content-type)"/>
31+
<xsl:choose>
32+
<xsl:when test="element()">
33+
<xsl:apply-templates />
34+
</xsl:when>
35+
<xsl:otherwise>
36+
<xsl:sequence select="." />
37+
</xsl:otherwise>
38+
</xsl:choose>
1939
</xsl:template>
2040

2141
</xsl:stylesheet>

0 commit comments

Comments
 (0)