Start New Discussion within our Software Development Community

Hi,


This is going to be a xpath query. In the input xml, elemt 'e' is the fifth child of root element. Using the apply template and template match, am at element 'e'. How can i get the value, 5(fifth child), within the template, e. I tried using position, but its value is coming as 1. Also, I do not want to alter anything else, except the line ,
<xsl:value-of select ="position()"/>, which is below <xsl:variable name="posi">.

Hi,


This is going to be a xpath query. In the input xml, elemt 'e' is the fifth child of root element. Using the apply template and template match, am at element 'e'. How can i get the value, 5(fifth child), within the template, e. I tried using position, but its value is coming as 1. Also, I do not want to alter anything else, except the line ,
<xsl:value-of select ="position()"/>, which is below <xsl:variable name="posi">.

Here also some problem with attachments. Please find the files below

input.xml

<Root>
    <a>123</a>
    <b>321</b>
    <c>897</c>
    <d>011</d>
    <e>456</e>
</Root>

xsl file

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">     
            <xsl:apply-templates select="/*/e"/>      
    </xsl:template>

    <xsl:template match="e">
    <result>
        <xsl:variable name="posi">
            <xsl:value-of select ="position()"/>
        </xsl:variable>
         <xsl:value-of select ="$posi"/>       
        </result>

    </xsl:template>
</xsl:stylesheet>
This article has been dead for over six months. Start a new discussion instead.