0

我试图了解 xsl:element 如何正常工作,并且我有这个测试转换:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml">

    <xsl:template match="test">
        <output>
            <test1/>
            <xsl:element name="test2"/>
            <xsl:variable name="three" select="3"/>
            <xsl:element name="test{$three}"/>
        </output>
    </xsl:template>
</xsl:stylesheet>

应用于本文档时:

<?xml version="1.0" encoding="UTF-8"?>
<test/>

我使用 xsltproc 得到这个结果

<?xml version="1.0"?>
<output xmlns="http://www.w3.org/1999/xhtml">
    <test1/>
    <test2/>
    <test3 xmlns=""/>
</output>

为什么 test3 节点与 test1 和 test2 不在同一个命名空间中?

4

1 回答 1

0

使用 Visual Studio 并让它应用 XSLT 我得到了以下内容(为便于阅读而格式化),所以我会说这是 xsltproc 中的一个错误。

<?xml version="1.0" encoding="utf-8"?>
<output xmlns="http://www.w3.org/1999/xhtml">
  <test1 />
  <test2 />
  <test3 />
</output>
于 2013-09-04T00:20:28.950 回答