SPFE Documentation | Collections > SPFE Function Reference > satisfies-condition
Function: satisfies-condition
satisfies-condition(conditions-list as item()*, tokens-list as item()*, index as item()*) as xs:boolean
- Description
-
A recursive function that checks a series of conditions against a series of condition tokens and returns true if there is a match. It takes account of conditions joined by a plus sign, returning true only if both conditions are satisfied. This is a helper function for the sf:conditions-met function.
- Return value
-
Return type: xs:boolean
True if the conditions match, otherwise false.
- Source file
-
$SPFEOT_HOME/1.0/scripts/common/utility-functions.xsl
Parameters
- conditions-list
-
Type: item()*
A sequence consisting of conditions attached to an element.
- tokens-list
-
Type: item()*
A sequence consisting of the condition tokens specified in the build.
- index
-
Type: item()*
The index in the tokens-list to check in this recursion.
Definition
<xsl:function name="sf:satisfies-condition" as="xs:boolean">
<xsl:param name="conditions-list"/>
<xsl:param name="tokens-list"/>
<xsl:value-of select="sf:satisfies-condition($conditions-list, $tokens-list, 1)"/>
</xsl:function>
<xsl:function name="sf:satisfies-condition" as="xs:boolean">
<xsl:param name="conditions-list"/>
<xsl:param name="tokens-list"/>
<xsl:param name="index"/>
<xsl:variable name="and-tokens" select="tokenize($tokens-list[$index], '\+')"/>
<xsl:choose >
<xsl:when test="every $item in $and-tokens satisfies $item=$conditions-list">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:when test="$index lt count($tokens-list)">
<xsl:value-of select="sf:satisfies-condition($conditions-list, $tokens-list, $index + 1)"/>
</xsl:when>
<xsl:otherwise >
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>