, where I want to...">

XSLT if expression syntax combining more than one expression

Trying to combine an if statement with <xsl:if test="expression">, where I want to have multiple expressions together, to execute an order of operations like this psuedocode:

if (Number != '' and (Name != '' or PreferredName != '')) {// code here}

Essentially, I want to do this in <xsl:if>:

<xsl:if text="Number != '' and (Name != '' or PreferredName != '')">

but I’m not sure about the syntax expression, I don’t think I can do ()something like this because I haven’t seen it anywhere. I couldn’t easily find expression syntax on the Internet, it might be XPath, but I'm not sure if XPath supports ()grouping expressions. I'm not an XSL / XML / XSD 'expert, so I don’t know if the expression is even XPath, or what.

I would prefer not to do nested instructions <xsl:if>if possible, and want to stick to <xsl:if>not <xsl:choose>.

I'm sure this is probably the simple answer, but stuck here. Thank.

+3
source share
1 answer

The conditional operator xsl:iffor beginners needs xsl:templateor another xsl element as the parent.
The syntax will be similar to the following:

<xsl:template>
    ... preliminary xsl statements ...
    <xsl:if test="Number != '' and (Name != '' or PreferredName != '')">
        ... further xsl statements (the code you were referring to ...
    </xsl:if>
    ... other xsl stataments ...
</xsl:template>

Further advise: study the use of xslt, in particular templates and their application (and the type of automatic cycle).

+5
source

All Articles