[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: WML input problem
What exactly is your problem? I tested it with this input:
<root> <input type="checkbox" name="musicpref_rnb" checked="checked">R&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&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&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&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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|