我想使用XMLT动态生成一个XML文件,该文件将另一个XML文件作为输入。我可以在此转换输出中消除名称空间声明吗?
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="data">
<xsl:apply-templates select="books" />
</xsl:template>
<xsl:template match="books">
<books>
<xsl:apply-templates select="chapters" />
</books>
</xsl:template>
<xsl:template match="chapters">
<chapter name="{@name}" source="{@source}"
xmlns:xi="http://www.w3c.org/2001/XInclude">
<xsl:apply-templates select="pages" />
</chapter>
</xsl:template>
<xsl:template match="pages" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include>
<xsl:value-of select="@name" />
</xi:include>
</xsl:template>
</xsl:stylesheet>
我希望的输出如下。
<chapter
xmlns:xi="http://www.w3c.org/2001/XInclude" name="chapter1">
<xi:include>page1</xi:include>
<xi:include>page2</xi:include>
<xi:include>page3</xi:include>
</chapter>
不幸的是,我的代码生成下面的输出。
<chapter
xmlns:xi="http://www.w3c.org/2001/XInclude" name="chapter1">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude">page1</xi:include>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude">page2</xi:include>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude">page3</xi:include>
</chapter>
有没有一种方法可以消除命名空间的实际URI,因为我可以使用xi:include tages without them?
超爽。非常感谢你。 – lightonphiri 2011-05-02 16:27:06