简体   繁体   English

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

[英]XSL element with multiple namespace with different prefix

I wanna create an element in my XSL 1.0 with some namespace Just like this:我想在我的 XSL 1.0 中创建一个带有命名空间的元素,就像这样:

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

For some reason I can't use XSL 2.0, with <xsl:namespace> extension, there is only one allowed namespace declared for each element in XSL 1.0,how should I do?出于某种原因,我不能使用带有<xsl:namespace>扩展名的 XSL 2.0,在 XSL 1.0 中为每个元素只声明了一个允许的名称空间,我该怎么办?

Regards,问候,

Works for me.为我工作。

If I make the file test.xsl :如果我制作文件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>

And then run it然后运行它

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

with this version info:使用此版本信息:

$ 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

Try the W3C XSLT 2.0 Spec: Creating Namespace Nodes .尝试 W3C XSLT 2.0 规范:创建命名空间节点 The gist of it is that you can create elements within other elements to put those namespaces into scope.它的要点是您可以在其他元素中创建元素以将这些名称空间放入范围。

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