user3783243
user3783243

Reputation: 5224

XSL Two Conditions Expression If Test

I can get my 2 expressions to process as I want with:

<xsl:if test="string-length(.) > 15">
    <xsl:if test="not(contains(., ' '))">
        <xsl:attribute name="font-size">5pt</xsl:attribute>
    </xsl:if>
</xsl:if>

however I'm not clear why I can't just write it as one test:

<xsl:if test="string-length(.) > 15 && not(contains(., ' '))">
    <xsl:attribute name="font-size">5pt</xsl:attribute>
</xsl:if>

this throws back an unknown error with my processor (Apache XSL FO).

I'm trying to test the current node I'm in to see if it contains more than 15 characters and no white space. If that match is met I reduce the font size to 5pt.

Upvotes: 0

Views: 386

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167401

The expression language used in XSLT is XPath, in XSLT 2.0 it is XPath 2.0. The boolean and operator just has the English name so string-length(.) > 15 and not(contains(., ' ')) is all you need.

Upvotes: 1

Related Questions