我一直在努力让同一个 xsl 文件处理两个(或更多)XML 文件。
我遵循了这篇文章中的步骤:在 XML/XSL 文件中包含一个 XML 文件,但我无法让它工作。
我似乎无法加载要处理的文件,没有错误。
这是第一个 xm 文件 - Dial_Stats_MWB:
<?xml version="1.0" encoding="utf-8"?>
<UK_Products_Pipeline>
<LastFinishCode>
<SiteName>UK</SiteName>
<LastFinishCode>Agent Logout</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
<LastFinishCode>
<SiteName>UK</SiteName>
<LastFinishCode>Busy</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
<LastFinishCode>
<SiteName>UK</SiteName>
<LastFinishCode>BW Sale</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
</UK_Products_Pipeline>
第二个文件 - Dial_Stats_UK:
<?xml version="1.0" encoding="utf-8"?>
<UK_Products_Pipeline>
<LastFinishCode>
<SiteName>MWB</SiteName>
<LastFinishCode>Bearer Capability Not Presently Authorized (ISDN Cause Code 57)</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
<LastFinishCode>
<SiteName>MWB</SiteName>
<LastFinishCode>Confirmed Booking</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
<LastFinishCode>
<SiteName>MWB</SiteName>
<LastFinishCode>Lost</LastFinishCode>
<Numbers>1</Numbers>
</LastFinishCode>
</UK_Products_Pipeline>
XSL 文件:
<?xml version="1.0" encoding='utf-8'?>
<xsl:stylesheet xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<title> XSLT with XML included </title>
</head>
<body style="background-color:lightblue;color:green">
<table cellSpacing="0" border="1" cellPadding="2">
<!-- Set Variables -->
<xsl:variable name="external">
<xsl:copy-of select="document('D:\DATA\Marquee\dial_stats_UK.xml')/*"/>
</xsl:variable>
<!-- Process Data Start -->
<xsl:for-each select="//UK_Products_Pipeline/LastFinishCode">
<tr>
<xsl:if test="SiteName ='MWB'">
<td>
<xsl:value-of select="SiteName"/>
</td>
<td>
<xsl:value-of select="LastFinishCode"/>
</td>
<td>
<xsl:value-of select="Numbers"/>
</td>
</xsl:if>
</tr>
</xsl:for-each>
<!-- Process File Data Start -->
<xsl:call-template name="ExternalData">
<xsl:with-param name="data" select="$external"/>
</xsl:call-template>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="ExternalData">
<xsl:param name="data"/>
<xsl:variable name="external">
<xsl:copy-of select="document('D:\DATA\Marquee\dial_stats_UK.xml')/*"/>
</xsl:variable>
<table cellSpacing="0" border="1" cellPadding="2" style="background-color:white;color:black">
<tr>
<td>
I do see this.
</td>
</tr>
<!-- Process External Data -->
<xsl:for-each select="//UK_Products_Pipeline/LastFinishCode">
<tr>
<td>
<xsl:value-of select="SiteName"/>
</td>
</tr>
<tr>
<xsl:if test="SiteName ='UK'">
<td>
<xsl:value-of select="SiteName"/>
</td>
<td>
<xsl:value-of select="LastFinishCode"/>
</td>
<td>
<xsl:value-of select="Numbers"/>
</td>
</xsl:if>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
当处理发生时,再次处理相同的文件而不是第二个文件。
我不知道您是否可以就我在这里做错了什么给我任何建议?