简体   繁体   English

XSLT

[英]XSLT <xsl:when test="

I am trying to write an XSL document that tests if an outside parameter value is equal to a particular value in the input XML document. 我正在尝试编写一个XSL文档,以测试外部参数值是否等于输入XML文档中的特定值。

The input XML document has multiple elements at the same level and I need to test each of the same level elements to see if they match the ID string. 输入的XML文档在同一级别具有多个元素,我需要测试每个相同级别的元素以查看它们是否与ID字符串匹配。 For example, there may be 5 elements called "WBScode" and each of them needs to be tested. 例如,可能有5个称为“ WBScode”的元素,并且每个元素都需要进行测试。 If any element matches the value, the xsl when statement needs to be returned, if not, the otherwise statement is returned. 如果有任何元素与该值匹配,则需要返回xsl when语句,如果不匹配,则返回else语句。

Below is the code I have, but what happens is it only tests the first element it finds in the document. 下面是我的代码,但是发生的是它仅测试了它在文档中找到的第一个元素。 How do I modify it to test each element of the document? 如何修改它以测试文档的每个元素?

  <xsl:choose>
      <xsl:when test="//Projects/Project/WBSs/WBS/WBSCode = $idStr">update</xsl:when>
      <xsl:otherwise>create</xsl:otherwise>
  </xsl:choose>

it only tests the first element it finds in the document 它仅测试在文档中找到的第一个元素

You are wrong about that. 你错了。 It tests every WBSCode element in turn and returns true when any one of them matches the value. 它依次测试每个WBSCode元素,并在其中任何一个与该值匹配时返回true。

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

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