【问题标题】:Attribute transformation using XSLT使用 XSLT 进行属性转换
【发布时间】:2013-08-15 02:50:20
【问题描述】:

我正在创建 XSLT 转换。 我的源 XML 包含具有 InstrumentType 属性的元素 Order:

<Order InstrumentType="FWD">

现在,作为转换过程的一部分,我必须在以下条件下使用 属性值:

<xsl:if test="$InstrumentType='SPOT'">
...
</xsl:if>

我正在寻找某种方法将 属性值 转换为 XSLT 中的 InstrumentType variable。 感谢您的帮助。

【问题讨论】:

  • 为什么需要一个变量?不能直接用@InstrumentType吗?
  • &lt;xsl:variable name="InstrumentType" select="@InstrumentType" /&gt;
  • 我尝试使用@InstrumentType 但我没有得到属性的值。调试时,我看到值类型 item()。还有其他建议还是我遗漏了什么?

标签: xml xslt transformation


【解决方案1】:

也许你有默认命名空间问题。然后就可以使用了

<xsl:if test="@*[local-name()='InstrumentType' and .='SPOT']"></xsl:if>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 2018-09-22
    • 2019-09-26
    • 2012-08-24
    • 2010-10-13
    相关资源
    最近更新 更多