|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: For-each iteration problem
Hi Kaerstin,
>I have a piece of xml that will be printed out as html checkboxes or radio
boxes depending on the value of the multiple
>variable (which will be radio or checkbox)... I was unable to get this to
work easily, and the code I am using now seems
>to put an extra/blank input box before each value...
You need to assign the 'multiple' and 'label' parameters. In your case it
would be adding some expression to the select attribute of the <xsl:param>.
I aslo took the liberty to change the value you are adding to the input
controls.
With your XML, the following XSL
<?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/possibleValues" />
</xsl:template>
<xsl:template match="possibleValues" >
<xsl:param name="multiple">Checkbox</xsl:param>
<xsl:param name="label">rb</xsl:param>
<xsl:for-each select="node()" >
<input type="{$multiple}" name="{$label}" value="{.}">
<xsl:value-of select="node()" />
</input>  
<xsl:if test="position() mod 4 = 0">
<br />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Produces the output using Radio (the checkboxes can be achieved by replacing
'Radio' with 'Checkbox'):
<input type="Checkbox" name="rb" value="image">image??
<input type="Checkbox" name="rb" value="webpage">webpage??
<input type="Checkbox" name="rb" value="text">text??
<input type="Checkbox" name="rb" value="number">number??
<br>
<input type="Checkbox" name="rb" value="money">money??
<input type="Checkbox" name="rb" value="animal">animal??
<input type="Checkbox" name="rb" value="mojo">mojo??
HTH
Cheers, Pieter
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
|

Cart








