PHP Classes

File: xul_elements.xsl

Recommend this page to a friend!
  Classes of Herman Veluwenkamp   HV WDDX Metadata   xul_elements.xsl   Download  
File: xul_elements.xsl
Role: Auxiliary data
Content type: text/plain
Description: XUL Form Widgets
Class: HV WDDX Metadata
Generates XUL and HTML forms based on XML config.
Author: By
Last change:
Date: 19 years ago
Size: 11,651 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="xml" indent="yes" omit-xml-declaration ="yes"/> <xsl:template name="element"> <xsl:variable name="name"><xsl:value-of select="struct/var[@name='name']/string"/></xsl:variable> <xsl:choose> <!-- TEXT FIELD --> <xsl:when test="var[@name='type']/string='text'"> <textbox type="text"> <xsl:attribute name="id"><xsl:value-of select="var[@name='name']/string"/>[1]</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="var[@name='selected']/string"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > </textbox> </xsl:when> <!-- PASSWORD FIELD --> <xsl:when test="var[@name='type']/string='password'"> <textbox type="password"> <xsl:attribute name="id"><xsl:value-of select="var[@name='name']/string"/>[1]</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="var[@name='selected']/string"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > </textbox> </xsl:when> <!-- DATE FIELD --> <xsl:when test="var[@name='type']/string='date'"> <date> <xsl:attribute name="id"><xsl:value-of select="var[@name='name']/string"/>[1]</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="var[@name='selected']/string"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > </date> </xsl:when> <!-- TIME FIELD --> <xsl:when test="var[@name='type']/string='time'"> <time> <xsl:attribute name="id"><xsl:value-of select="var[@name='name']/string"/>[1]</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="var[@name='selected']/string"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > </time> </xsl:when> <!-- TEXTBOX FIELD --> <xsl:when test="var[@name='type']/string='textbox'"> <textboxmulti type="text" flex="1"> <xsl:attribute name="id"><xsl:value-of select="var[@name='name']/string"/>[1]</xsl:attribute> <xsl:attribute name="value"><xsl:value-of select="var[@name='selected']/string"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > </textboxmulti> </xsl:when> <!-- POPUP FIELD --> <xsl:when test="var[@name='type']/string='popup'"> <xsl:variable name="id"><xsl:value-of select="var[@name='name']/string"/></xsl:variable> <xsl:variable name="default"><xsl:value-of select="var[@name='selected']/string"/></xsl:variable> <menulist id="{$id}"> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > <menupopup> <!-- ITERATE OVER OPTIONS --> <xsl:for-each select="var[@name='option']/array/struct"> <xsl:variable name="value"><xsl:value-of select="var[@name='value']/string"/></xsl:variable> <xsl:variable name="label"> <xsl:choose> <xsl:when test="var[@name='label']/string"> <xsl:value-of select="var[@name='label']/string"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <menuitem selected="false" value="{$value}" label="{$label}"> <xsl:attribute name="id"> <xsl:value-of select="$id"/> <xsl:text>[</xsl:text><xsl:number format="0" count="var[@name='option']/array/struct"/> <xsl:text>]</xsl:text> </xsl:attribute> <xsl:if test="$default=$value"> <xsl:attribute name="selected">true</xsl:attribute> </xsl:if> </menuitem> </xsl:for-each> </menupopup> </menulist> </xsl:when> <!-- RADIO BUTTON FIELD --> <xsl:when test="var[@name='type']/string='radio'"> <xsl:variable name="id"><xsl:value-of select="var[@name='name']/string"/></xsl:variable> <xsl:variable name="default"><xsl:value-of select="var[@name='selected']/string"/></xsl:variable> <radiogroup id="{$id}"> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > <!-- ITERATE OVER OPTIONS --> <xsl:for-each select="var[@name='option']/array/struct"> <xsl:variable name="value"><xsl:value-of select="var[@name='value']/string"/></xsl:variable> <xsl:variable name="label"> <xsl:choose> <xsl:when test="var[@name='label']/string"> <xsl:value-of select="var[@name='label']/string"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <radio value="{$value}" label="{$label}" group="{$id}"> <xsl:attribute name="id"> <xsl:value-of select="$id"/> <xsl:text>[</xsl:text><xsl:number format="0" count="var[@name='option']/array/struct"/> <xsl:text>]</xsl:text> </xsl:attribute> <!-- flag selected value --> <xsl:if test="$default=$value"> <xsl:attribute name="selected">true</xsl:attribute> </xsl:if> </radio> </xsl:for-each> </radiogroup> </xsl:when> <!-- LISTBOX FIELD --> <xsl:when test="var[@name='type']/string='listbox'"> <xsl:variable name="id"><xsl:value-of select="var[@name='name']/string"/></xsl:variable> <listbox seltype="multiple" id="{$id}"> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > <!-- ITERATE OVER OPTIONS --> <xsl:for-each select="var[@name='option']/array/struct"> <xsl:variable name="value"><xsl:value-of select="var[@name='value']/string"/></xsl:variable> <xsl:variable name="label"><xsl:value-of select="var[@name='label']/string"/></xsl:variable> <listitem value="{$value}" label="{$label}"> <xsl:attribute name="id"> <xsl:value-of select="$id"/> <xsl:text>[</xsl:text><xsl:number format="0" count="var[@name='option']/array/struct"/> <xsl:text>]</xsl:text> </xsl:attribute> <!-- CAN HAVE MULTIPLE VALUES --> <xsl:for-each select="../../../var[@name='selected']/array/string"> <xsl:if test=".=$value"> <xsl:attribute name="selected">true</xsl:attribute> </xsl:if> </xsl:for-each> </listitem> </xsl:for-each> </listbox> </xsl:when> <!-- CHECKLIST FIELD --> <xsl:when test="var[@name='type']/string='checklist'"> <xsl:variable name="id"><xsl:value-of select="var[@name='name']/string"/></xsl:variable> <listbox seltype="multiple"> <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > <!-- ITERATE OVER OPTIONS --> <xsl:for-each select="var[@name='option']/array/struct"> <xsl:variable name="value"><xsl:value-of select="var[@name='value']/string"/></xsl:variable> <xsl:variable name="label"><xsl:value-of select="var[@name='label']/string"/></xsl:variable> <listitem type="checkbox" value="{$value}" label="{$label}"> <xsl:attribute name="id"> <xsl:value-of select="$id"/> <xsl:text>[</xsl:text><xsl:number format="0" count="var[@name='option']/array/struct"/> <xsl:text>]</xsl:text> </xsl:attribute> <!-- CAN HAVE MULTIPLE VALUES --> <xsl:for-each select="../../../var[@name='selected']/array/string"> <xsl:if test=".=$value"> <xsl:attribute name="selected">true</xsl:attribute> <xsl:attribute name="checked">true</xsl:attribute> </xsl:if> </xsl:for-each> </listitem> </xsl:for-each> </listbox> </xsl:when> <!-- CHECKBOX FIELD --> <xsl:when test="var[@name='type']/string='checkbox'"> <xsl:variable name="id"><xsl:value-of select="var[@name='name']/string"/></xsl:variable> <vbox id="{$id}"> <!-- INSERT NODE ATTRIBUTES --> <xsl:for-each select="var[@name='node-attribute']/array/struct"> <xsl:attribute name="{var[@name='name']/string}"><xsl:value-of select="var[@name='value']/string"/></xsl:attribute> </xsl:for-each > <!-- ITERATE OVER OPTIONS --> <xsl:for-each select="var[@name='option']/array/struct"> <xsl:variable name="value"><xsl:value-of select="var[@name='value']/string"/></xsl:variable> <xsl:variable name="label"><xsl:value-of select="var[@name='label']/string"/></xsl:variable> <checkbox value="{$value}" label="{$label}"> <xsl:attribute name="id"> <xsl:value-of select="$id"/> <xsl:text>[</xsl:text><xsl:number format="0" count="var[@name='option']/array/struct"/> <xsl:text>]</xsl:text> </xsl:attribute> <!-- CAN HAVE MULTIPLE VALUES --> <xsl:for-each select="../../../var[@name='selected']/array/string"> <xsl:if test=".=$value"> <xsl:attribute name="checked">true</xsl:attribute> </xsl:if> </xsl:for-each> </checkbox> </xsl:for-each> </vbox> </xsl:when> <!-- UNKNOWN FIELD --> <xsl:otherwise> <label value="unknown Field"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>