Xml – How to dynamically get value attribute value of a row using XSLT

xmlxslt

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?

Best Answer

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]"/>
Related Topic