Login   Register  
PHP Classes
elePHPant
Icontem

File: formClientValidatedJsArray.xsl

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Herman Veluwenkamp  >  xmlForm  >  formClientValidatedJsArray.xsl  >  Download  
File: formClientValidatedJsArray.xsl
Role: ???
Content type: text/plain
Description: XSL Stylesheet to Generate Javascript Array for Client Validation Example
Class: xmlForm
Generates a form in HTML.
Author: By
Last change:
Date: 2002-02-26 00:17
Size: 1,060 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="form-config">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <xsl:for-each select="var">
field[<xsl:number format="1"/>] = Array(
  '<xsl:value-of select="@name"/>',             <!-- name of data field  -->
  '<xsl:value-of select="@type"/>',             <!-- type of field being displayed  -->
  '<xsl:value-of select="description"/>',       <!-- description of field  -->
  <xsl:value-of select="validation-regexp"/>,   <!-- data validation regular expression  -->
  '<xsl:value-of select="validation-message"/>',<!-- message to display when data is invalid  -->
  <xsl:choose>
    <xsl:when test='@type="text"'>'1'</xsl:when>
    <xsl:when test='@type="textarea"'>'1'</xsl:when>
    <xsl:otherwise>'<xsl:value-of select = "count(option)" />'</xsl:otherwise>
  </xsl:choose>
);       
    </xsl:for-each>
</SCRIPT>
</xsl:template>

</xsl:stylesheet>