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