XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Savant KingSubject: form controls with xslt
Author: Savant King
Date: 11 Jan 2012 05:10 PM
Hi everybody,

I have this:
XML:
[code]
<?xml version="1.0" encoding="utf-8" ?>

<FORM ID="1" Formtitle="Form Builder">
<FIELDS>
<!--Label Form-->
<FIELDSET Legend ="Form for contact" >
<PAGE title="Page Title" id="page_1">
<!--end label-->
<Field type ="formTitle1" Label ="Title"/>
<Button type ="Button" Label ="btnSave" Text="Save" Required ="0"/>

<!--TEXTFIELD EMAIL-->
<FIELD type="TextBox" label="Email:" required="true">
<PROPERTIES>
<PROPERTY name="ID">EMAIL_ADRESS</PROPERTY>
</PROPERTIES>
</FIELD>
<!--TEXTFIELD EMAIL-->
<!--TEXTFIELD FIRST NAME-->
<FIELD type="TextBox" label="First Name:" required="true">
<PROPERTIES>
<PROPERTY name="ID">FIRST_NAME</PROPERTY>
</PROPERTIES>
</FIELD>
<!--END TEXTFIELD FIRST NAME-->
<!--TextField lastname-->
<FIELD type="TextBox" label="Last Name:" required="true">
<PROPERTIES>
<PROPERTY name="ID">LAST_NAME</PROPERTY>
</PROPERTIES>
</FIELD>
<!--END-->
<!--TextArea description-->
<FIELD type="TextBox" label="Description:">
<PROPERTIES>
<PROPERTY name="ID">DESCRIPTION</PROPERTY>
<PROPERTY name="TextMode">MultiLine</PROPERTY>
<PROPERTY name="Cols">40</PROPERTY>
<PROPERTY name="Rows">4</PROPERTY>
</PROPERTIES>
</FIELD>
<!--End description-->
<!--RadioButtons-->
<FIELD Type="RadioButtonList" label="Gender">
<PROPERTIES>
<PROPERTY name="ID">IS_GENDER</PROPERTY>
<PROPERTY name="RepeatColumns">1</PROPERTY>
<PROPERTY name="RepeatDirection">Vertical</PROPERTY>
<PROPERTY name="RepeatLayout">Table</PROPERTY>
<PROPERTY name="TextAlign">Right</PROPERTY>
</PROPERTIES>
<LISTITEM value ="1">Female</LISTITEM>
<LISTITEM value ="0">Man</LISTITEM>
</FIELD>
<!--DropDownBox1-->
<FIELD type="DropDownList" id="DropDownList1" label="testDrop">
<OPTION value="1">Niels, Engelen</OPTION>
<OPTION value="2">Marilyn, VosSavant</OPTION>
</FIELD>
<!-- creating select box Test -->
<FIELD type="DropDownList" label="Title:">
<PROPERTIES>
<PROPERTY name="ID">TITLE</PROPERTY>
</PROPERTIES>
<LISTITEMS>
<LISTITEM value="">HAllO1</LISTITEM>
<LISTITEM value="1">HALLO2</LISTITEM>
<LISTITEM value="2">HALLO3</LISTITEM>
<LISTITEM value="3">HALLO4</LISTITEM>
<LISTITEM value="4">HALLO5</LISTITEM>
</LISTITEMS>
</FIELD>
</PAGE>
</FIELDSET>
</FIELDS>
</FORM>
[/code]

and xslt:
[code]
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:param name="pageid"/>
<html>
<body>
<h1>
<xsl:value-of select="@Formtitle"/>
</h1>


<!--TEST-->

<!-- start form page -->
<table cellpadding="0" cellspacing="5">

<!-- set title of the current page -->
<tr>
<td colspan="3" align="center" style="font-size:25px">
<xsl:value-of select="FORM/FIELDS/PAGE[@id=$pageid]/@title" />
</td>
</tr>
<tr>
<td colspan="3" style="height:20px"></td>
</tr>

<!-- iterate through page fields -->
<xsl:for-each select="FORM/FIELDS/PAGE[@id=$pageid]/FIELDS/FIELD">

<xsl:element name="tr">

<xsl:attribute name="id">
TR_<xsl:value-of select="PROPERTIES/PROPERTY[@name='ID']"></xsl:value-of>
</xsl:attribute>

<!-- hide the row -->
<xsl:if test="@display='none'">
<xsl:attribute name="style">display:none;</xsl:attribute>
</xsl:if>

<xsl:choose>

<!-- html control -->
<xsl:when test="@type='HTML'">
<td colspan="3">
&lt;!-- #include file="<xsl:value-of select="@src"></xsl:value-of>" --&gt;
</td>
</xsl:when>


<!-- other controls -->
<xsl:otherwise>

<!-- field label column -->
<td valign="top">
<xsl:value-of select="@label" />
</td>

<!-- field column -->
<td>

<!-- field element -->
<xsl:element name="{@type}">
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:for-each select="./PROPERTIES/PROPERTY">
<xsl:attribute name="{@name}">
<xsl:value-of select="current()"></xsl:value-of>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="./LISTITEMS/LISTITEM">
<ListItem value="{@value}">
<xsl:value-of select="current()"></xsl:value-of>
</ListItem>
</xsl:for-each>
</xsl:element>

</td>

<!-- validation message column -->
<td>
<xsl:if test="@required='true'">
<RequiredFieldValidator ErrorMessage="Required" runat="server" ControlToValidate="{PROPERTIES/PROPERTY[@name='ID']}" />
</xsl:if>

<xsl:if test="@validation='Date'">
<CompareValidator ErrorMessage="Dates Only" runat="server" Operator="DataTypeCheck" Type="Date" ControlToValidate="{PROPERTIES/PROPERTY[@name='ID']}" />
</xsl:if>

<xsl:if test="@validation='Number'">
<CompareValidator ErrorMessage="Numbers Only" runat="server" Operator="DataTypeCheck" Type="Integer" ControlToValidate="{PROPERTIES/PROPERTY[@name='ID']}" />
</xsl:if>

<xsl:if test="@validation='Currency'">
<CompareValidator ErrorMessage="Currency Only" runat="server" Operator="DataTypeCheck" Type="Currency" ControlToValidate="{PROPERTIES/PROPERTY[@name='ID']}" />
</xsl:if>
</td>
</xsl:otherwise>

</xsl:choose>
</xsl:element>

</xsl:for-each>
</table>

<!--END TEST-->



<form id="1" action="myurl.com">
<fieldset>
<legend>
<xsl:value-of select="Fields/Fieldset/@Legend"/>
</legend>

<!--TextFieldAchternaam-->
<xsl:for-each select="Fields/Fieldset/Field">
<xsl:if test="@Type = 'Text'">
<xsl:if test="@Required='1'">
<label>
<xsl:value-of select="@Label"/>
</label>
<br/>
<input type="text" name="{@FieldName}" class="jqueryValidate"/>
</xsl:if>
<xsl:if test="@Required='0'">
<br/>

<!--TextFieldVoornaam-->
<label>
<xsl:value-of select="@Label1"/>
</label>
<br/>
<input type="text" name="{@FieldName}" class ="jqueryValidate"/>
</xsl:if>
</xsl:if>

<xsl:if test="@Required='0'">
<xsl:for-each select="Option">
<label>
<xsl:value-of select="Label"/>

</label>
<input type="text" name="Field2"/>
</xsl:for-each>
</xsl:if>
<br/>

<xsl:if test="@Type = 'Radio'">
<xsl:if test="@Required='1'">
<label>
<xsl:value-of select="@Label"/>
</label>
<input type="radio" name="{@FieldName}" class="jqueryValidate"/>
<br/>
</xsl:if>
<br/>

<!--RadioButtonGeslacht-->
<xsl:if test="@Required='0'">
<label>
<xsl:value-of select="@Label"/>
</label>
<xsl:for-each select="Option">
<label>
<xsl:value-of select="@Text"/>
</label>
<input type="radio" name="Field4" Value="1"/>
</xsl:for-each>
</xsl:if>
<br/>

<!--DropDownList1-->
<xsl:if test="@Required='0'">
<label>
<xsl:value-of select="@DropDownList1"/>
</label>
<xsl:for-each select="Option">
<input type="DropDownList" name="DropDownList1"/>
</xsl:for-each>
</xsl:if>
<br/>

<!--DropDownList2-->
<xsl:if test="@Required='0'">
<label>
<xsl:value-of select="@DropDownList"/>
</label>
<xsl:for-each select="@PROPERTIES/PROPERTY">
<xsl:for-each select="./LISTITEMS/LISTITEM">

<input type="DropDownList" name="ID"/>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
<br/>


<!--Button Send-->
<xsl:if test="@Required='0'">
<label>
<xsl:value-of select="@Text"/>
</label>
<xsl:for-each select="@PROPERTIES/PROPERTY">

<input type="button" name="Button1" Select="@Label"/>
</xsl:for-each>
</xsl:if>
<br/>


<!--Validation Form-->

</xsl:if>
</xsl:for-each>
</fieldset>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
[/code]

But I dont see the form controls.

THX for helping.

Posttop
Ivan PedruzziSubject: form controls with xslt
Author: Ivan Pedruzzi
Date: 11 Jan 2012 05:37 PM

Which Stylus Studio version are you running?

<<"These boards are part of the Stylus Studio Developer Network. They are a service to users of Stylus Studio only.">>

If you download, register and start developing XSLT using Stylus
Studio you will have access to the forum resources.

http://www.stylusstudio.com/xml_download.html

Hope this helps
Stylus Studio Team


Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.