我無法獲取要顯示的數據。只有XML文檔中的第一個元素顯示出來。我需要一份貢獻者名單,按貢獻的金額分組。這裏是我的代碼:訪問多個文檔中的數據
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="persons" select="document('persons.xml')" />
<xsl:key name="contAmount" match="donation" use="@amount" />
<xsl:key name="pinID" match="donation" use="@pin" />
<xsl:key name="personID" match="person" use="@pid" />
<xsl:template match="/">
<html>
<head>
<title>Lighthouse Charitable Trust</title>
<link href="money.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>Contribution Report</h2>
<p>Total Donation Amount:
<xsl:value-of select="format-number(sum(//donations/donation/@amount), '$###,000')" />
</p>
<p>Total Donors:
<xsl:value-of select="count($persons/persons/person)" />
</p>
<p>
<xsl:variable name="cid" select="//donations/donation/@pin" />
<xsl:for-each select="$persons">
<xsl:value-of select="key('personID', $cid)/firstName" />  
<xsl:value-of select="key('personID', $cid)/lastName" /> <br />
<xsl:value-of select="key('personID', $cid)/street" /> <br />
<xsl:value-of select="key('personID', $cid)/city" />,
<xsl:value-of select="key('personID', $cid)/state" />  
<xsl:value-of select="key('personID', $cid)/zip" /> <br />
<xsl:value-of select="key('personID', $cid)/phone" /> <br />
</xsl:for-each>
</p>
<a href="#{generate-id()}">
<xsl:value-of select="person" />
</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
謝謝!
請編輯您的問題並提供以下缺失和重要信息:一個小的源XML文檔以及本文檔的確切結果。另外,解釋轉換必須實施的規則。 – 2012-02-13 03:37:03