Mercurial > pub > ModelGenerator
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 11:14162f9133a1 | 12:191b81b2052b | 
|---|---|
| 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"> | |
| 9 <xsl:call-template name="write-value"> | |
| 10 <xsl:with-param name="value" select="key('members',concat(generate-id(..),local-name(.)))[last()]"/> | |
| 11 </xsl:call-template> | |
| 12 </xsl:template> | |
| 13 | |
| 14 <xsl:template match="address" mode="json-member-value"> | |
| 15 <xsl:call-template name="write-array"/> | |
| 16 </xsl:template> | |
| 17 | |
| 18 <xsl:template match="work | home"> | |
| 19 <address> | |
| 20 <_type><xsl:value-of select="local-name(.)"/></_type> | |
| 21 <xsl:copy-of select="*"/> | |
| 22 </address> | |
| 23 </xsl:template> | |
| 24 | |
| 25 <xsl:template match="@*"> | |
| 26 <xsl:element name="{local-name(.)}" > | |
| 27 <xsl:value-of select="."/> | |
| 28 </xsl:element> | |
| 29 </xsl:template> | |
| 30 | |
| 31 </xsl:stylesheet> | 
