annotate xslt/json-person.xsl @ 12:191b81b2052b

first version of the xslt transform from xml to json
author cin
date Mon, 09 Apr 2018 06:43:46 +0300
parents
children 197a850b1f6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
1 <xsl:stylesheet version="1.0"
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
4 xmlns:exsl="http://exslt.org/common">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
5 <xsl:import href="json.xsl"/>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
6 <xsl:output method="text" />
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
7
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
8 <xsl:template match="firstName | lastName" mode="json-member-value">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
9 <xsl:call-template name="write-value">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
10 <xsl:with-param name="value" select="key('members',concat(generate-id(..),local-name(.)))[last()]"/>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
11 </xsl:call-template>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
12 </xsl:template>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
13
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
14 <xsl:template match="address" mode="json-member-value">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
15 <xsl:call-template name="write-array"/>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
16 </xsl:template>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
17
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
18 <xsl:template match="work | home">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
19 <address>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
20 <_type><xsl:value-of select="local-name(.)"/></_type>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
21 <xsl:copy-of select="*"/>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
22 </address>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
23 </xsl:template>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
24
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
25 <xsl:template match="@*">
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
26 <xsl:element name="{local-name(.)}" >
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
27 <xsl:value-of select="."/>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
28 </xsl:element>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
29 </xsl:template>
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
30
191b81b2052b first version of the xslt transform from xml to json
cin
parents:
diff changeset
31 </xsl:stylesheet>