Reputation: 5076
I have to create one table using XSLT and CSS. The table should look like
ID FNAME
1 AA
2 BB
XML:
<students>
<studentDetails id="1" fname="AA"/>
<studentDetails id="2" fname="BB"/>
</students>
XSLT so far: I have traverse upto studentDetails and then
<td >
<xsl:call-template name="zz">
<xsl:with-param name="child-name" select="'id'"/>
</xsl:call-template>
</td>
<xsl:template name="zz">
<xsl:param name="child-name"/>
<xsl:value-of select="*[name(@id) = $child-name]"/>//should print 1 and then 2 in next row
Can somebody suggest where i am going wrong?
Upvotes: 1
Views: 3098
Reputation: 143081
try
<xsl:value-of select="attribute::*[name() = $child-name]"/>
instead.
Edit: I have just read through Dewfy's answer. This is equivalent to what he proposed. Except for his "at first" part is an alternative to this, not something you have to in addition to changing xsl:value-of
.
Upvotes: 2
Reputation: 23624
At first don't pass "'id'" just use "id" At second = pattern * selects node, but you need attr (@*), so you need write:
<xsl:value-of select="@*[name()=$child-name]"/>
Upvotes: 5