XSLT XPath first note with attribute -
i want select first column without @type='hidden'
in first <xsl:if>
, , other nodes without @type='hidden'
in second <xsl:if>
. want give a
in first <xsl:if>
class.
xml:
<row type="header"> <column type="hidden">href</column> <column type="hidden">mnr</column> <column type="number">vnr</column> <column type="text">description</column> <column type="text">document</column> <column type="date">date</column> </row>
wanted output:
<tr> <th> <a class="sortingarrow" onclick="sort(this)"> vnr </a> </th> <th> <a onclick="sort(this)"> description </a> </th> <th> <a onclick="sort(this)"> document </a> </th> <th> <a onclick="sort(this)"> date </a> </th> </tr>
xslt used:
<xsl:template match="row[@type='header']/column" mode="columnsone" > <xsl:if test="(column[@type!='hidden'])[1]"> <th> <a class="sortingarrow" onclick="sort(this)"> <xsl:value-of select="." /> </a> </th> </xsl:if> <!-- other if statement --> </xsl:template>
it both of <xsl:if>
you can using templates this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" encoding="utf-8" indent="yes" /> <xsl:template match="column[not(@type = 'hidden')][position() = 1]"> <th> <a class="sortingarrow" onclick="sort(this)"> <xsl:value-of select="." /> </a> </th> </xsl:template> <xsl:template match="column[not(@type = 'hidden')][position() != 1]"> <th> <a onclick="sort(this)"> <xsl:value-of select="."/> </a> </th> </xsl:template> <xsl:template match="row[@type='header']"> <tr> <xsl:apply-templates select="column[not(@type = 'hidden')]"/> </tr> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment