我对 xsl 完全陌生。我正在尝试过滤此 xml 中的数据。
<SectorWeightings Currency="xxx">
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="A B||16.324500000000" Date="8/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="C||16.744400000000" Date="7/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="C S||10.177400000000" Date="8/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="C S||8.8950000000000" Date="7/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="E||12.841600000000" Date="8/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="E||13.551700000000" Date="7/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="Fi S||14.157900000000" Date="8/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="Fi S||15.221200000000" Date="7/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="H Care||12.508900000000" Date="7/31/2011" />
<SectorWeightingsEntry Type="Sector Name||Sector Weight (%)" Value="H Care||13.198200000000" Date="8/31/2011" />
</SectorWeightings>
这是我用来过滤数据的代码
<xsl:for-each select="FundPricePerf/Group[@Name=nds']/SubGroup[@Name='S']/Fund[@FundCode='xx']/SectorWeightings">
<tr>
<td> <xsl:value-of select="SectorWeightingsEntry[@Type='Sector Name||Sector Weight (%)']/@Value"/> </td>
</tr>
</xsl:for-each>
上面的代码将仅填充 AB||16.324500000000 的第一行。
如何打印整个列表?
更新
<?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"
>
<html>
<body>
<h2> zzzzzzzzz </h2>
<table style="width:50%;font-size:12px;" cellspacing="0" cellpadding="0">
<tr style="width:50%; text-align:left;background-color:E6F1F9;">
<th> xxxxx </th>
<th> yyyyy </th>
</tr>
<xsl:apply-templates
select="FundPricePerf/Group[@Name='xxxxx']/SubGroup[@Name='S']/Fund[@FundCode='vv']/SectorWeightings/SectorWeightingsEntry[@Type='Sector Name||Sector Weight (%)']"/>
<xsl:template match="SectorWeightingsEntry">
<tr>
<td>
<xsl:value-of select="@Value"/>
</td>
</tr>
</xsl:template>
</table>
</body>
</html>
</xsl:stylesheet>