0
我有2個XSL樣式表,其中兩個變換元件<Group id="all">
:包括XSL模板和合並輸出
輸出應該被合併,而是正在被main.xslt
或include.xslt
覆蓋。 (取決於訂單)
我寧願不修改include.xslt
文件,因爲它在其他樣式表中共享,不應修改。
main.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="include.xslt"/>
<xsl:template match="Group[@id='all']">
<xsl:copy>
<xsl:copy-of select="@*|node()" />
<xsl:apply-templates select="document('part1.xml')" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
include.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Group[@id='all']">
<xsl:copy>
<xsl:copy-of select="@*|node()" />
<xsl:apply-templates select="document('part2.xml')" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
input.xml中
<?xml version="1.0"?>
<Group id="all">
testdata below:
</Group>
part1.xml
<?xml version="1.0"?>
<data id="test1">
Here is some test data.
</data>
part2.xml
<?xml version="1.0"?>
<data id="test2">
Here is some more data.
</data>
實際輸出:
<?xml version="1.0"?>
<Group id="all">
testdata below:
Here is some test data.
</Group>
預期輸出:
<?xml version="1.0"?>
<Group id="all">
testdata below:
Here is some test data.
Here is some more data.
</Group>
感謝您的回答,不幸的是,使用導入不起作用,因爲在包含文件中還有其他模板,這些模板都需要在'main.xslt'中指定。你有一個使用node-set()的例子嗎? – 0x00
我使用節點集解決了問題,稍後將發佈解決方案 – 0x00