12
|
1 <xsl:stylesheet version="1.0"
|
|
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4 xmlns:exsl="http://exslt.org/common">
|
|
5 <xsl:import href="json.xsl"/>
|
|
6 <xsl:output method="text" />
|
|
7
|
|
8 <xsl:template match="firstName | lastName" mode="json-member-value">
|
13
|
9 <xsl:param name="values" select="."/>
|
|
10 <xsl:call-template name="write-array">
|
|
11 <xsl:with-param name="values" select="$values"/>
|
12
|
12 </xsl:call-template>
|
|
13 </xsl:template>
|
|
14
|
13
|
15 <xsl:template match="address | work | home" mode="json-object">
|
|
16 <xsl:call-template name="write-member-string">
|
|
17 <xsl:with-param name="name" select="'_type'"/>
|
|
18 <xsl:with-param name="value" select="local-name(.)"/>
|
|
19 </xsl:call-template>
|
|
20
|
|
21 <xsl:variable name="members" select="@order | *"/>
|
|
22 <xsl:if test="$members">
|
|
23 <xsl:call-template name="write-separator"/>
|
|
24 <xsl:call-template name="write-members">
|
|
25 <xsl:with-param name="members" select="$members"/>
|
|
26 </xsl:call-template>
|
|
27 </xsl:if>
|
12
|
28 </xsl:template>
|
|
29
|
13
|
30 <xsl:template match="person" mode="json-object">
|
|
31 <xsl:variable name="address" select="home | work | address"/>
|
|
32 <xsl:variable name="members" select="*[not(self::home | self::work | self::address)]"/>
|
|
33
|
|
34 <xsl:if test="$address">
|
|
35 <xsl:call-template name="write-member-array">
|
|
36 <xsl:with-param name="name" select="'address'"/>
|
|
37 <xsl:with-param name="values" select="$address"/>
|
|
38 </xsl:call-template>
|
|
39 </xsl:if>
|
|
40
|
|
41 <xsl:if test="count($address) > 0 and count($members) > 0">
|
|
42 <xsl:call-template name="write-separator"/>
|
|
43 </xsl:if>
|
|
44
|
|
45 <xsl:call-template name="write-members">
|
|
46 <xsl:with-param name="members" select="$members"/>
|
|
47 </xsl:call-template>
|
|
48
|
12
|
49 </xsl:template>
|
|
50
|
|
51
|
|
52 </xsl:stylesheet> |