I have an XML file as below, and I want to transform it with xslt.
<?xml version="1.0" encoding="utf-8"?>
<root>
<s1 name="kfb" />
<s1 name="kfb" />
<s1 name="kfb" />
<s1 name="kfb" />
<s1 name="kfb" />
<s1 name="kfb" />
<summary>
<r1 value="1" />
<r1 value="5" />
<r1 value="c" />
<r1 value="h" />
<r1 value="3" />
<r1 value="1" />
</summary>
</root>
what I want to achieve is: when do the for-each of "s1" elements, I want to get the corresponding "r1"'s "value" attbute value just according the index/postion("s1" elements count equal "r1") . the xslt I wrote as below, but it does not work, can anyone give a help? thanks.
<?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="html" indent="yes"/>
<xsl:template mode="getr1" match="summary" >
<xsl:param name="index"/>
<xsl:value-of select="r1[$index][@value]"/>
</xsl:template>
<xsl:template match="/">
<html>
<body>
<ul>
<xsl:for-each select="root/s1">
<xsl:variable name="i" select="position()"/>
<li>
<xsl:value-of select ="@name"/>
:
<!--<xsl:apply-templates mode="getr1" select="/root/summary">
<xsl:with-param name="index" select="$i" />
</xsl:apply-templates>-->
<!--I want to get the corresponding r1's value according to the index -->
<!-- but above code is not work.-->
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>