다음과 같은 XML 파일이 있는데 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>
내가 무엇을 달성하고자하는 것은 : 할 때를 위해 - 각 "S1"요소, 내가 "(단지 인덱스 /받은 위치에 따라 해당"R1 "의"값 "attbute 값을 얻으려면 s1 "요소의 수가"r1 "과 같음). 내가 아래에 쓴 xslt,하지만 작동하지 않는다, 아무도 도움을 줄 수 있습니까? 감사.
<?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>
오히려이어야한다입니다 'r1 [$ index] [@ value]'가 아니라'value '이다. – Tomalak