简体   繁体   中英

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.

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. For example, there may be 5 elements called "WBScode" and each of them needs to be tested. If any element matches the value, the xsl when statement needs to be returned, if not, the otherwise statement is returned.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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