jeudi 10 septembre 2020

XML/XSL if else substring

i would like to substring a variable in XML/XSL with an if clause, if the entry is too long.

I tried something like this, but it isn't working like that.

                    <xsl:variable id="newId" select="./newId"/>
                    <xsl:template match="newId">
                        <xsl:choose>
                            <xsl:when test="string-length() &lt; 15">
                                <xsl:value-of select="newId"/>  
                            </xsl:when>
                            <xsl:otherwise>
                                 <xsl:value-of select="substring(.,1,15)" />
                                 <br>
                                 <xsl:value-of select="substring(.,16)" />
                                 </br>
                            </xsl:otherwise>
                        </xsl:choose>

Aucun commentaire:

Enregistrer un commentaire