我即將合併XML文件(並添加元信息),其相對路徑在我的輸入XML文件中指定。我要合併的文件位於一個名爲「文件」的子目錄 輸入文件的結構如下XSLT打開其他xml文件
<files>
<file>
<path>files/firstfile.xml</path>
</file>
<file>
<path>files/secondfile.xml</path>
</file>
</files>
的firstfile.xml和secondfile.xml具有以下結構
<tables>
<table name = "...">
...
</table>
...
<tables>
我想將一個文件的所有表節點放在一個組中,並向它添加元信息。所以我寫了下面的XSLT樣式表:
<xsl:template match="/">
<tables>
<xsl:apply-templates/>
</tables>
</xsl:template>
<xsl:template name = "enrichWithMetaInformation" match = "file">
<xsl:apply-templates select="document(./path)/tables">
<xsl:with-param name="file" select="."/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="tables">
<group>
<meta>
...Some meta data ...
</meta>
<xsl:copy-of select="./table"/>
</group>
</xsl:template>
對於每一個文件,我得到一個錯誤:
The system could not find the file specified.
它指出,空節點集已經返回(這樣的文件無法加載)。有沒有人知道如何解決這個問題?
Cheers
@IanRoberts,當document()的參數是一個節點時,路徑將相對於該節點的基本URI進行解釋。 –
@MichaelKay我站在糾正,我發現規範的形式語言,而不是有時難以解析...... –