[xsl] An easy problem

Subject: [xsl] An easy problem
From: "alex ek" <alexek@xxxxxxxxxxxxxx>
Date: 27 Jul 2002 14:51:12 -0000
Hello All
I have a problem in xslt style sheet in which i am writing template match for the form tag of HTML.
I hev some thing like this in HTML
<form method="POST" action="choice.html">
<p>Enter the choices</p>
<p><input type="checkbox" name="name1" checked="checked" />America<br />
<input type="checkbox" name="name2" checked="checked" />Europe<br />
<input type="checkbox" name="name3" />Asia </p>
<p>Enter the gender</p>
<input type="radio" name="gender" value="mal" />male<br />
<input type="radio" name="gender" value="fem" /> female
</form>


And i want to convert it in this form

<do label="submit" type="accept">
<go href="choice.html" method="post">
<postfield name="name1" value="$name1"/>
<postfield name="name2" value="$name2"/>
<postfield name="name3" value="$name3"/>
<postfield name="gender" value="$gender"/>
</go>
</do>

And the style sheet i am using is

 <xsl:template match="form">
        <do type="accept" label="submit">
         <go href="@action" method="@method">
          <xsl:choose>
           <xsl:when test="input[@type='checkbox']">
            <xsl:for-each select="input[@type='checkbox']">
             <postfield name="@name" value="$@name">
            </xsl:for-each>
           </xsl:when>
           <xsl:when test="input[@type='radio']>
            <postfield name=@name" value="$@name">
           </xsl:when>
           </xsl:choose>
          </go>
        </do>
       <xsl:apply-templates select="*"/>
      </xsl:template>

Though i should check in input[@type='radio'] that name of the preceding sibling is same or not because in type radio name is same for all.so it should come only once .
But this is not working even after removing the when condition of input type radio and simply using type check box only .
It is giving error .
What is wrong in it and what should be the correct way.
Itried various combinations even removing for-each loop and giving only one input type =checkbox in input but it is not working .
The rest of style sheet working .
if i use only


<xsl:template match="form">
<p><xsl:apply-templates select="*"/>
</xsl:template>
It is working but as obvious not creating any post field which is required for form handling.
Need help.
Alexek


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread