MaKSiNG
Technical User
- Dec 4, 2003
- 19
I have the following XML which define the options available to a radio button and which option is checked as default:
I am using the following piece of XSL to transform this into HTML:
My problem is two-fold:
1. I am building the <input> tag bit by bit using <xsl:element> and <xsl:attribute> and populating the attributes with variables, text and content from the XML. If you look at the value attribute in blue, I am building it using 2 variables and text. When I look at the rendered HTML I get lots of spaces between the various components I am trying to put together in a single string. This stops the HTML being read as a single line and I am not getting a radio button displayed. I have taken the resulting HTML and deleted all the space from these attributes and it works fine. How do I stop all these extra spaces being added?
2. I am having difficulty locating the node I need in the highlighted red <xsl:if> statement. My <xsl:for-each> statement puts me on a certain level of nodes; the item node with attribute description, but how do I now specify the item node with attribute default, which is also on the same level?
Thx,
MaKS
Code:
<item name="options">
<value>
<item name="description">
<value>Yes</value>
</item>
<item name="default"/>
</value>
<value>
<item name="description">
<value>No</value>
</item>
<item name="default">
<value>yes</value>
</item>
</value>
</item>
I am using the following piece of XSL to transform this into HTML:
Code:
<xsl:for-each select="value/item/value/item[@name='description']">
<xsl:variable name="pos2" select="position () - 1"/>
<tr valign="top">
<td class="cn-cont-nopad" height="10" width="10">
<xsl:element name="input">
<xsl:attribute name="type">radio
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="$rdBtnName" />
</xsl:attribute>
<xsl:attribute name="id">radiobutton0_
<xsl:value-of select="$pos"/>
</xsl:attribute>
[COLOR=blue] <xsl:attribute name="value">radiobutton0_
<xsl:value-of select="$pos"/>_
<xsl:value-of select="$pos2"/>
</xsl:attribute>[/color]
<xsl:attribute name="class">cn-form-field
</xsl:attribute>
[COLOR=red] <xsl:if test="item[@name='default']/value='yes'">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>[/color]
</xsl:element>
</td>
<td class="cn-form-radio-text" height="10" width="190">
<xsl:value-of select="value" />
</td>
</tr>
</xsl:for-each>
My problem is two-fold:
1. I am building the <input> tag bit by bit using <xsl:element> and <xsl:attribute> and populating the attributes with variables, text and content from the XML. If you look at the value attribute in blue, I am building it using 2 variables and text. When I look at the rendered HTML I get lots of spaces between the various components I am trying to put together in a single string. This stops the HTML being read as a single line and I am not getting a radio button displayed. I have taken the resulting HTML and deleted all the space from these attributes and it works fine. How do I stop all these extra spaces being added?
2. I am having difficulty locating the node I need in the highlighted red <xsl:if> statement. My <xsl:for-each> statement puts me on a certain level of nodes; the item node with attribute description, but how do I now specify the item node with attribute default, which is also on the same level?
Thx,
MaKS