0

我想在我的 XSL 1.0 中创建一个带有一些命名空间的元素就像这样:

<element xmlns:a = '...' xmlns:b = '...' xmlns = '...' >

由于某种原因,我不能使用带有<xsl:namespace>扩展名的 XSL 2.0,在 XSL 1.0 中为每个元素声明了一个允许的命名空间,我该怎么办?

问候,

4

2 回答 2

0

为我工作。

如果我制作文件test.xsl

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <root>
        <multins xmlns:abc="http://example.com/1" xmlns:def="http://example.com/2" />
    </root>
</xsl:template>

</xsl:stylesheet>

然后运行它

xsltproc test.xsl test.xsl
<?xml version="1.0"?>
<root><multins xmlns:abc="http://example.com/1" xmlns:def="http://example.com/2"/></root>

使用此版本信息:

$ xsltproc --version
Using libxml 20703, libxslt 10124 and libexslt 813
xsltproc was compiled against libxml 20632, libxslt 10124 and libexslt 813
libxslt 10124 was compiled against libxml 20632
libexslt 813 was compiled against libxml 20632
于 2009-07-21T07:26:58.473 回答
0

试试 W3C XSLT 2.0 规范:创建命名空间节点。它的要点是您可以在其他元素中创建元素以将这些名称空间放入范围内。

Example:

<!--XSLT 2.0-->
<data xsi:type="xs:integer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <xsl:namespace name="xs" select="'http://www.w3.org/2001/XMLSchema'"/>
  <xsl:text>42</xsl:text>
</data>

<!--XSLT 1.0-->
<data xsi:type="xs:integer"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  42
</data>
于 2009-07-21T07:26:59.287 回答