<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "text"/>
<xsl:template match="data/struct">
field = new Array();
<xsl:for-each select="var/struct">
<xsl:variable name="fieldItem">field['<xsl:value-of select="var[@name='name']/string"/>']</xsl:variable>
<xsl:value-of select="$fieldItem"/>=new Array();
<xsl:value-of select="$fieldItem"/>.count = "<xsl:number format="1" count="var"/>";
<xsl:value-of select="$fieldItem"/>.type = "<xsl:value-of select="var[@name='type']/string"/>";
<xsl:value-of select="$fieldItem"/>.description = "<xsl:value-of select="var[@name='description']/string"/>";
<xsl:value-of select="$fieldItem"/>.validate = <xsl:value-of select="var[@name='validation-regexp']/string"/>;
<xsl:value-of select="$fieldItem"/>.expected = "<xsl:value-of select="var[@name='validation-message']/string"/>";
<xsl:choose>
<xsl:when test='@type="text"'>
<xsl:value-of select="$fieldItem"/>.numOptions = "1";
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$fieldItem"/>.numOptions = "<xsl:value-of select = "count(var[@name='option']/array/struct)" />";
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|