XSLT list item position issue

283 views Asked by At

pls check the below code. I am matching the list element and as per the below code the position() function returns correct number of the element with in ul elements i.e 1,2,3 where as if i do the test with position i get only ss,ss,ss . Can anyone let me know where am missing ?

XSL-FO

<xsl:template match="html:li" priority="2">
    <fo:list-item>
       ...
       <xsl:value-of select="position()"/> -- this returns 1,2,3
       <xsl:if test="position() = 1">
        <xsl:text>ss</xsl:text> -- only executes 
      </xsl:if>
      <xsl:if test="position() = 2">
        <xsl:text>ssddddd</xsl:text> -- does not only execute
      </xsl:if>
      <xsl:if test="position() = 3">
        <xsl:text>sskkkkkkkkk</xsl:text> -- does not only execute
      </xsl:if> 
    </fo:list-item>
</xsl:template

XSL

<xsl:template match="list">
    <xsl:if test="list.item">
        <xsl:variable name="styleAttr">             
            <xsl:text>margin-top: 1em;</xsl:text>
        </xsl:variable>

        <div>
            <xsl:if test="string-length($styleAttr) &gt; 0">
                <xsl:attribute name="style">
                    <xsl:value-of select="$styleAttr"/>
                </xsl:attribute>
            </xsl:if>

            <ul>                    
                <xsl:apply-templates select="node()[not(self::list)]" />
            </ul>
        </div>
    </xsl:if>
</xsl:template>

<xsl:template match="list.item" priority="1">
    <li style="padding: 0;">
        <div style="margin-bottom: 0.5em;">
            <xsl:apply-templates />
            <xsl:if test="following-sibling::node()[1][self::list]">
                <xsl:apply-templates select="following-sibling::node()[1]" />
            </xsl:if>
        </div>
    </li>
</xsl:template>
0

There are 0 answers