繁体   English   中英

具有多个具有不同前缀的名称空间的 XSL 元素

[英]XSL element with multiple namespace with different prefix

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

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

出于某种原因,我不能使用带有<xsl:namespace>扩展名的 XSL 2.0,在 XSL 1.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

尝试 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM