Unusual Template Behavior with XSL
Posted
by
bobber205
on Stack Overflow
See other posts from Stack Overflow
or by bobber205
Published on 2010-12-30T01:27:42Z
Indexed on
2010/12/30
13:54 UTC
Read the original article
Hit count: 184
xslt
Experiencing some very odd behavior with, what should be, a very simple use of XSL and XSLT.
Here's a code sample.
<xsl:template match="check">
<div class="check">
<xsl:apply-templates mode="check">
<xsl:with-param name="checkName">testVariable</xsl:with-param>
</xsl:apple-templates>
</div>
</xsl:template>
The template called above
<xsl:template match="option" mode="check">
<xsl:param name="checkName" />
<div class="option">
<input type="checkbox">
</input>
<label>
testText
</label>
</div>
</xsl:template>
Pretty simple right? It should, for each instance of a instance in the XML create a checkbox in a with a hard coded label.
However, what I'm getting is
<div class="check"></div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
<div class="check"></div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
<div class="option>Checkbox stuff here</div>
Here's some sample XML
<check><option key="1"/><option key="0"/><option
key="0"/><option key="0"/><option
key="0"/></check>
Anyone know what's going on? :D
© Stack Overflow or respective owner