0
<root>    
<row type="header">
 <column>href</column>
 <column>other</column>
</row>
<row type="data">
 <column>a</column>
 <column>b</column>
</row>
</root>

XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
    <xsl:for-each select="row">
        <xsl:if test="">
            <xsl:value-of select="column"/>
        </xsl:if>
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I want to know the position of column which contains "a" in it based on condition row type="data" only

Rudramuni TP
  • 1,268
  • 2
  • 16
  • 26
Anshu Kumar
  • 51
  • 1
  • 7

1 Answers1

1

Try this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="root">
    <xsl:for-each select="row[@type='data']/column">
        <xsl:if test="contains(., 'a')">
            <xsl:value-of select="position()"/>
        </xsl:if>
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Rudramuni TP
  • 1,268
  • 2
  • 16
  • 26