[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: AW: An easy problem

Subject: Re: AW: An easy problem
From: "alex ek" <alexek@xxxxxxxxxxxxxx>
Date: 29 Jul 2002 10:28:49 -0000
style sheet for input
Thanks thomas
I tried that .i would not say that it is not working but there is some thing which is not correct but i am not getting what?


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='text'] or input[@type='password'] or input[@type='checkbox']">
<postfield name="{@name}" value="{concat('$',@name)}"/>
</xsl:when>
<xsl:when test="input[@type='radio']">
<xsl:for-each select="//input[generate-id(.)=generate-id(key('radios', @name))]">
<postfield name="{@name}" value="{concat('$',@name)}"/>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</go>
</do>
<xsl:apply-templates select="*"/>
</xsl:template>


i tried your style sheet but it was processing the input types twice as i have written template match style sheet for input type separately. like
<xsl:template match="input[@type='text']">
<input name="{@name}" type="{@type}">
<xsl:apply-templates/>
</input>
<xsl:template match="input[@type='password']">
<input name="{@name}" type="{@type}">
<xsl:apply-templates/>
</input>
<xsl:template match="input[@type='']">
<input name="{@name}" type="text">
<xsl:apply-templates/>
</input>
<xsl template match="input[@type='radio'] and count( . | key('radiobutton', @name)[1] ) = 1">
<select name="{@name}">
<xsl:for-each select="key('radiobutton', @name)">
<option>
<xsl:value-of select="following- sibling::text()[1]"/>
</option>
</xsl:for-each>
</select>
<xsl:template match="input[@type='checkbox']">
<select name="{@name}" >
<option value="{@value}">
<xsl:value-of select="following-sibling::text()[1]"/>
</option>
</select>
</xsl:template>



So now the output i am getting is


<do type="accept" label="submit">
<go href="choice.html" method="post">
 <postfield name="gender" value="$gender"/>
 </go>
 </do> input your name: <input name="name" type="text"/><br/>
    input password :<input name="pwd" type="password"/>
    Enter the choices<select name="name1">
      <option value="">America</option>
    </select><br/>
<select name="name2"><option value="">Europe</option>
   </select><br/>
<select name="name3"><option value="">Asia </option>
   </select>
Enter the gender
<select name="gender">
<option value="mal">male</option>
<option value="fem"> female</option>
</select>

Where as what it should be like

input your name:
<input name="name" type="text"/>
<br/>
input password :
<input name="pwd" type="password"/>
Enter the choices
<select name="name1">
<option value="">
America
</option>
</select>
<br/>
<select name="name2">
<option value="">
Europe
</option>
</select>
<br/>
<select name="name3">
<option value="">
Asia
</option>
</select>
Enter the gender
<select name="gender">
<option value="mal">
male
</option>
<option value="fem">
 female
</option>
</select>
<br/>
<do label="submit" type="accept">
<go href="choice.html" method="post">
<postfield name="name" value="$name"/>
<postfield name="pwd" value="$pwd"/>
<postfield name="name1" value="$name1"/>
<postfield name="name2" value="$name2"/>
<postfield name="name3" value="$name3"/>
<postfield name="gender" value="$gender"/>
</go>
</do>

and are these two same
<xsl:for-each select="//input[generate-id(.)=generate-id(key('radios', @name))]">
<xsl:for-each select="@type='radio' and count( . | key('radiobutton', @name)[1] ) = 1">


And now the question

What is the problem .
alexek


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:key name="radios" match="//input[@type='radio']" use="@name"/>
<xsl:template match="form">
<do type="accept" label="submit">
<go href="{@action}" method="{@method}">


<xsl:apply-templates select=".//input[@type='checkbox']"/>

<xsl:for-each
select="//input[generate-id(.)=generate-id(key('radios', @name))]">


<postfield name="{@name}" value="{concat('$',@name)}"/>

</xsl:for-each>

      </go>
    </do>
    <xsl:apply-templates select="*"/>
  </xsl:template>

  <xsl:template match="input[@type='checkbox']">
    <postfield name="{@name}" value="{concat('$',@name)}"/>
  </xsl:template>

</xsl:stylesheet>



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.