0
我想将模板复制到输出文档中,但是模板标签中出现附加属性。我正在使用相同的文件进行转换输入。为什么在转换后出现附加属性
这就是:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../Product/templates.xsl"/> <!--in fb changees-->
<xsl:output method="xml"/>
<xsl:template name="root" match="/">
<xsl:copy-of select="/xsl:stylesheet/xsl:template[@name='test-case-1']"/>
</xsl:template>
<xsl:template name="test-case-1" >
<test-case-1 name="koza">
<xsl:value-of select="100"/>
</test-case-1>
</xsl:template>
</xsl:stylesheet>
这是输出:
<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="test-case-1">
<test-case-1 name="koza">
<xsl:value-of select="100"/>
</test-case-1>
让我困扰的是xmlns:xsl
作为<xsl:template>
标签的属性出现。为什么这个命名空间属性出现在xsl:template?
谢谢。
版 我期望的输出是这样的:
<xsl:template name="test-case-1">
<test-case-1 name="koza">
<xsl:value-of select="100"/>
</test-case-1>
</xsl:template>
因为这是定义'xsl:'前缀的地方。 – EJP
有没有办法避免它? –
'xmlns:xls'不是一个属性,而是一个名称空间声明。如果您使用前缀“xsl:”复制元素,则应该存在名称空间声明。看起来你正在将XSLT应用到自己。你能在这种情况下显示你期望的确切输出吗?谢谢! –