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

Re: Re: WML input problem

Subject: Re: Re: WML input problem
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 08 Jul 2002 22:55:16 +0200
wml checkbox
What exactly is your problem? I tested it with this input:

<root>
<input type="checkbox" name="musicpref_rnb" checked="checked">R&amp;B</input>
<input type="checkbox" name="musicpref_jazz" checked="checked">Jazz</input>
<input type="checkbox" name="musicpref_blues" checked="checked">Blues</input><br/>
<input type="checkbox" name="musicpref_newage" checked="checked"> New Age</input>


<input type="radio" name="category" value="liv" checked="checked">Living</input>
<input type="radio" name="category" value="din">Dining</input>
<input type="radio" name="category" value="bed">Bedroom</input>


<input type="checkbox" name="musicpref2_rnb" checked="checked">R&amp;B</input>
<input type="checkbox" name="musicpref2_jazz" checked="checked">Jazz</input>
<input type="checkbox" name="musicpref2_blues" checked="checked">Blues</input>
<input type="checkbox" name="musicpref2_newage" checked="checked"> New Age</input>


<input type="radio" name="category2" value="liv" checked="checked">Living</input>
<input type="radio" name="category2" value="din">Dining</input>
<input type="radio" name="category2" value="bed">Bedroom</input>
</root>


with this stylesheet:

<xsl:key name="radios" match="input[@type='radio']" use="@name"/>
<xsl:key name="checkboxes" match="input[@type='checkbox']" use="substring-before(@name, '_')"/>


<xsl:template match="root">
    <html>
        <head><title>test</title></head>
        <body>
            <xsl:apply-templates/>
        </body>
    </html>
</xsl:template>

<xsl:template match="input">
<xsl:choose>
<xsl:when test="@type='text' or @type='password'">
<input name="{@name}" type="{@type}">
<xsl:apply-templates/>
</input>
</xsl:when>
<xsl:when test="@type='checkbox' and generate-id()=generate-id(key('checkboxes', substring-before(@name, '_')))">
<select name="{substring-before(@name, '_')}" multiple="multiple">
<xsl:for-each select="key('checkboxes', substring-before(@name, '_'))">
<option value="{substring-after(@name, '_')}">
<xsl:apply-templates/>
</option>
</xsl:for-each>
</select>
</xsl:when>
<xsl:when test="@type='radio' and generate-id()=generate-id(key('radios', @name))">
<select name="{@name}">
<xsl:for-each select="key('radios', @name)">
<option value="{@value}">
<xsl:apply-templates/>
</option>
</xsl:for-each>
</select>
</xsl:when>
</xsl:choose>
</xsl:template>


and I get this output:

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-16">
    <title>test</title>
  </head>
  <body>
    <select name="musicpref" multiple>
      <option value="rnb">R&amp;B</option>
      <option value="jazz">Jazz</option>
      <option value="blues">Blues</option>
      <option value="newage"> New Age</option>
    </select>
    <select name="category">
      <option value="liv">Living</option>
      <option value="din">Dining</option>
      <option value="bed">Bedroom</option>
    </select>
    <select name="musicpref2" multiple>
      <option value="rnb">R&amp;B</option>
      <option value="jazz">Jazz</option>
      <option value="blues">Blues</option>
      <option value="newage"> New Age</option>
    </select>
    <select name="category2">
      <option value="liv">Living</option>
      <option value="din">Dining</option>
      <option value="bed">Bedroom</option>
    </select>
  </body>
</html>

For checkboxes I use the underline '_' as delimiter between the name of the select box and the value of the resulting option.

The technique I use for the grouping is called Muenchian Method. With the key 'radios' the inputs are grouped by their @name. For the *first* input in one group a select-boy shell be created. This is reached by "generate-id() = generate-id(key('radios', @name))" It's only true for the first element in a group, because generate-id() on a node set reutrns a id of the first element in this node set.

For more information look at http://www.jenitennison.com/xslt/grouping/muenchian.xml or http://www.dpawson.co.uk/xsl/sect2/N4486.html.

Regards,

Joerg


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



Current Thread
  • Re: Re: WML input problem
    • ashu t - Mon, 8 Jul 2002 04:45:41 -0400 (EDT)
      • <Possible follow-ups>
      • ashu t - Mon, 8 Jul 2002 10:32:18 -0400 (EDT)
        • Joerg Heinicke - Mon, 8 Jul 2002 16:55:38 -0400 (EDT) <=
          • subbu - Mon, 8 Jul 2002 17:29:09 -0400 (EDT)
          • Jeni Tennison - Mon, 8 Jul 2002 18:33:38 -0400 (EDT)
          • subbu - Tue, 9 Jul 2002 04:59:40 -0400 (EDT)
          • subbu - Tue, 9 Jul 2002 08:40:53 -0400 (EDT)

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.