xsl-list
[Top] [All Lists]

RE: Generating form fields with xsl

2004-03-26 09:04:33
Hi Kaerstin,

just guessing that your XML would look something like

<dataElement>
        <name>Field Name</name>
        <description>Field Description</description>
        <visible>visible</visible>
        <display>textarea</display>
        <optional>optional</optional>
        <multipleAllowed>false</multipleAllowed>
        <possibleValues>
                <value>some text</value>
        </possibleValues>
</dataElement>

, the following stylesheet, which uses the fragment you sent,

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
        <xsl:apply-templates select="dataElement" />
</xsl:template>

<xsl:template match="dataElement" >
        <xsl:choose>
                <xsl:when test="display='textfield'">
                        <input type="text" name="{name}"/>
                </xsl:when>
                <xsl:when test="display='textarea'">
                        <textarea name="{name}">
                                <xsl:value-of select="possibleValues/value"
/>
                        </textarea>
                </xsl:when>
        </xsl:choose>
</xsl:template>

</xsl:stylesheet>

which outputs the following html:

<textarea name="Field Name">some text</textarea>

So, although I removed some of your code, your xsl was working fairly
well... if it is still not working for you please let us know.

<prs/>

-----Original Message-----
From: Andrew Curry [mailto:andrew(_dot_)curry(_at_)pa(_dot_)press(_dot_)net] 
Sent: Friday, March 26, 2004 9:51 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Generating form fields with xsl

 <xsl:choose><xsl:when test="display='textfield'"><input type="text"
name="{name}"/></xsl:when>
      <xsl:when test="display='textarea'"><textarea name="{name}"
</textarea>   </xsl:when>

you are missing a $ off name and if display is an attribute it will be
preceded by a $ or @ depending on the context i.e.

 <xsl:choose>
<xsl:when test="@display='textfield'">
<input type="text"name="{$name}"/>
</xsl:when>
<xsl:otherwise>
otherwise do something
</xsl:otherwise>
</xsl:choose>
----- Original Message -----
From: "Pieter Reint Siegers Kort" <pieter(_dot_)siegers(_at_)elnorte(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, March 26, 2004 3:48 PM
Subject: RE: [xsl] Generating form fields with xsl


Hi Kaerstin,

Please post your XML or an extract of it so we can determine the cause 
of your problem better, just like you did with the radio and check boxes.

<prs/>

-----Original Message-----
From: Johnson, Kaerstin [mailto:johns218(_at_)regis(_dot_)edu]
Sent: Friday, March 26, 2004 9:08 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Generating form fields with xsl


I have an xml page that gets translated into a html form using my xsl 
stylesheet. However when I try and create a textarea field, it doesnt
work.
How does one create a <textarea name=""></textarea> equivalent in xsl?

 I tried using an input with ttype textfield and also the way below: 
they dont seem to work.


 <xsl:choose><xsl:when test="display='textfield'"><input type="text"
name="{name}"/></xsl:when>
      <xsl:when test="display='textarea'"><textarea name="{name}"
</textarea>   </xsl:when>

         <xsl:otherwise>

            <xsl:apply-templates select="possibleValues">
            <xsl:with-param name="typo" select="display"/>
            <xsl:with-param name="multiple" select="$multiple"/>
              <xsl:with-param name="label" select="name"/>
                    </xsl:apply-templates>
           </xsl:otherwise>
       </xsl:choose>

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
You are subscribed as: pieter(_dot_)siegers(_at_)elnorte(_dot_)com To 
unsubscribe, go to:

http://lists.mulberrytech.com/unsub.php/xsl-list/pieter(_dot_)siegers(_at_)elnorte(_dot_)com
or e-mail:

<mailto:xsl-list-unsubscribe-pieter(_dot_)siegers=elnorte(_dot_)com(_at_)lists(_dot_)mulberrytech(_dot_)c
om>
--+--

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
You are subscribed as: andrew(_dot_)curry(_at_)pa(_dot_)press(_dot_)net To 
unsubscribe, go 
to:
http://lists.mulberrytech.com/unsub.php/xsl-list/andrew(_dot_)curry(_at_)pa(_dot_)press(_dot_)net
or e-mail:
<mailto:xsl-list-unsubscribe-andrew(_dot_)curry=pa(_dot_)press(_dot_)net(_at_)lists(_dot_)mulberrytech(_dot_)co
m>
--+--



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
You are subscribed as: pieter(_dot_)siegers(_at_)elnorte(_dot_)com To 
unsubscribe, go to:
http://lists.mulberrytech.com/unsub.php/xsl-list/pieter(_dot_)siegers(_at_)elnorte(_dot_)com
or e-mail:
<mailto:xsl-list-unsubscribe-pieter(_dot_)siegers=elnorte(_dot_)com(_at_)lists(_dot_)mulberrytech(_dot_)c
om>
--+--


<Prev in Thread] Current Thread [Next in Thread>