PHP Classes
elePHPant
Icontem

File: javascript.xsl

Recommend this page to a friend!
  Classes of Herman Veluwenkamp  >  HV WDDX Metadata  >  javascript.xsl  >  Download  
File: javascript.xsl
Role: Auxiliary data
Content type: text/plain
Description: XSL for generating javascript array
Class: HV WDDX Metadata
Generates XUL and HTML forms based on XML config.
Author: By
Last change:
Date: 15 years ago
Size: 1,267 bytes
 

 

Contents

Class file image Download
<?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>