【问题标题】:xslt adds "ns0" with the namespace attribute with root element, how to avoid this?xslt 使用带有根元素的命名空间属性添加“ns0”,如何避免这种情况?
【发布时间】:2012-05-17 10:33:09
【问题描述】:

我正在使用 xsl:element 的命名空间属性在结果 XML 中放置一个命名空间。它将命名空间放在那里,但像这样:

xmlns:ns0="http://...." 

并将 作为 。我想把命名空间不带“ns0”。

【问题讨论】:

  • 您能否更具体一点,您使用的 XSLT 处理器,您的代码看起来如何(XML 和 XSLT,期望的输出和当前输出)?
  • XSLT 这会导致:xmlns.mynamespaces.com/import " version="2.0" /> 我认为我使用的 xslt 处理器是 Xalan

标签: xml xslt


【解决方案1】:
<xsl:element name="myroot" namespace="xmlns.mynamespace.com/import">;
  <xsl:attribute name="version">
    <xsl:text>2.0</xsl:text>
  </xsl:attribute>
  <xsl:apply-templates />
</xsl:element>

只需将其重写为

<myroot xmlns="xmlns.mynamespace.com/import" version="2.0">
  <xsl:apply-templates />
</myroot>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 2011-02-10
    • 2016-02-18
    • 2010-10-27
    • 2012-08-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多