XML – Assign strings to variables according to conditions in XSLT

If a specific attribute returns a specific value, I want to assign a value to the variable. Here, if pr: all / [@ pr: name = current()/ @ cx: name] / pr: properties /(@ ls:middlename) is “cengie”, I want to assign the value “young” to the variable “person” “. Is that possible?

  name='person' select='pr:all/[@pr:name=current()/@cx:name]/pr:properties/(@ls:middlename)'>

You can put any xslt code in xsl:variable , And assign the result to a variable. In this case, you can use xsl:if to check your condition

 

young

If you want to use’else’ here, You can use xsl:choose instead.

If a specific attribute returns a specific value, I want to assign a value to the variable. Here, if pr:all / [@ pr:name = current()/ @ cx: name] / pr: properties / (@ ls: middlename) is “cengie”, I want to assign the value “young” to the variable “person”. Is that possible?

 name='person' select='pr:all/[@pr:name=current()/@cx: name]/pr:properties/(@ls:middlename)'>

You can put any xslt code In the xsl: variable, and assign the result to the variable. In this case, you can use xsl: if to check your condition

 

young

If you want to be here Using’else’, you can use xsl: choose instead.

Leave a Comment

Your email address will not be published.