adding html attribute to html element from xsl

Viewed 23

I am trying to have "id" attribute change to value i provide from xsl to existing html element "input", i tried with below xsl, ia m unable to get it. Can someone please give clue or solution or point me the right way to do it. html:

<cell type="html">
         <input type="checkbox" id="logshiftKey" />
</cell>

xslt:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml">
<xsl:variable name="rowIndex" select="1"/>

<xsl:template match="cell[@type='html']//*">
        <xsl:call-template name="associateRowIndexToCheckBox">
            <xsl:with-param name="rowIndex" select="$rowIndex"/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="associateRowIndexToCheckBox">
        <xsl:param name="rowIndex"/>
        <xsl:copy>
            <xsl:attribute name="id">$rowIndex</xsl:attribute>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Expected output:

<input type="checkbox" id="1"/>
0 Answers
Related