Debian Codegraph @

net/sf/saxon/data/xml-to-json-indent.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:xs="http://www.w3.org/2001/XMLSchema"
6 xmlns:j="http://www.w3.org/2005/xpath-functions/json"
7 exclude-result-prefixes="xs j"
8 version="3.0">
9
10 <xsl:import href="xml-to-json.xsl"/>
11
12 <xsl:param name="j:indent-spaces" as="xs:integer" select="3"/>
13
14 <xsl:param name="j:colon" as="xs:string"> : </xsl:param>
15
16 <xsl:template name="j:start-array">
17 <xsl:text> </xsl:text><xsl:value-of select="$j:start-array"/><xsl:text>&#xa;</xsl:text>
18 <xsl:variable name="depth" select="count(ancestor::*)"/>
19 <xsl:for-each select="1 to ($depth + 1) * $j:indent-spaces"><xsl:text> </xsl:text></xsl:for-each>
20 </xsl:template>
21
22 <xsl:template name="j:end-array">
23 <xsl:text> </xsl:text><xsl:value-of select="$j:end-array"/><xsl:text> </xsl:text>
24 </xsl:template>
25
26 <xsl:template name="j:start-map">
27 <xsl:text> </xsl:text><xsl:value-of select="$j:start-map"/><xsl:text>&#xa;</xsl:text>
28 <!-- <xsl:text> {&#xa;</xsl:text>-->
29 <xsl:variable name="depth" select="count(ancestor::*)"/>
30 <xsl:for-each select="1 to ($depth + 1) * $j:indent-spaces"><xsl:text> </xsl:text></xsl:for-each>
31 </xsl:template>
32
33 <xsl:template name="j:end-map">
34 <xsl:text> </xsl:text><xsl:value-of select="$j:end-map"/><xsl:text> </xsl:text>
35 <!--<xsl:text> } </xsl:text>-->
36 </xsl:template>
37
38 <xsl:template name="j:map-separator">
39 <xsl:variable name="depth" select="count(ancestor::*)"/>
40 <xsl:value-of select="$j:map-separator"/><xsl:text>&#xa;</xsl:text>
41 <!--<xsl:text>,&#xa;</xsl:text>-->
42 <xsl:for-each select="1 to $depth * $j:indent-spaces"><xsl:text> </xsl:text></xsl:for-each>
43 </xsl:template>
44
45 <xsl:template name="j:array-separator">
46 <xsl:variable name="depth" select="count(ancestor::*)"/>
47 <xsl:value-of select="$j:array-separator"/><xsl:text>&#xa;</xsl:text>
48 <!--<xsl:text>,&#xa;</xsl:text>-->
49 <xsl:for-each select="1 to $depth * $j:indent-spaces"><xsl:text> </xsl:text></xsl:for-each>
50 </xsl:template>
51
52 </xsl:stylesheet>