【问题标题】:Xsl if statement inside xsl for each statement: how?xsl if 语句在 xsl 中为每个语句:如何?
【发布时间】:2015-11-27 21:38:10
【问题描述】:

我有一个 xml:

<newsletter country="nl">
<shop id="1">
<primaryOffer type="hunt">

现在我有一个 xslt:

<xsl:for-each select="//shop[@id='1']">
< do A>
</xsl:for-each>

现在我正在寻找一个 if 语句,在每个语句的 xsl 中,它说: 如果primaryOffer type="hunt" 做A,否则做B

我该怎么做?

我试过了

<xsl:for-each select="//shop[@id='1']">
<xsl:if select="//primaryOffer[@type='hunt']">A</xsl:if>
B
</xsl:for-each>

这里是xml: http://frisokc111.111.axc.nl/feed/nl.xml

谢谢!

【问题讨论】:

标签: xml if-statement xslt


【解决方案1】:

知道了,谢谢

<xsl:choose>
   <xsl:when test="../primaryOffer[@type = 'hunt']">
      do a
   </xsl:when>
   <xsl:otherwise>
      do b
   </xsl:otherwise>
</xsl:choose>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    • 2011-04-20
    • 2015-01-26
    • 2010-10-29
    • 1970-01-01
    • 1970-01-01
    • 2023-02-26
    相关资源
    最近更新 更多