XSLT - boolean true if attribute value character length greater than 10

15,133

Solution 1

You want the string-length function:

<xsl:if test="string-length(@title) &gt; 10">

Solution 2

I believe it's string-length() you are after.

Share:
15,133

Related videos on Youtube

meder omuraliev
Author by

meder omuraliev

I began learning front end web development around 04-05, started my first program around 06 with PHP. Currently, I am a Web technologist specializing in full stack development and linux administration specializing with the LAMP stack ( HTML5, CSS3, PHP, Apache, MySQL). I also like to dabble in node.js, meteorjs, Python, django and in general like to mess with new technology/stacks. LinkedIn | [email protected]

Updated on June 04, 2022

Comments

  • meder omuraliev
    meder omuraliev almost 2 years

    I attempted this to count the total characters of my title attribute value, but it didn't seem to evaluate as I intended it to:

    <xsl:if test="count(@title)>10">
        <xsl:attribute name="class">double-line</xsl:attribute>
    </xsl:if>
    

    I also tried to append /text() to @title. It looks like I'm still off. Any suggestions?

  • meder omuraliev
    meder omuraliev almost 15 years
    Er - gt and lt instead of the literal?