indexOf - if part of a string contains "Text" for example.
1 2 if (pageName.indexOf("Text")!= -1)
DZone Snippets > Booma > xslt
12975 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Alan Coleman www.alancoleman.co.uk
1 2 if (pageName.indexOf("Text")!= -1)
1 2 <input type="text" name="sharesLook" onclick="this.value=''" > 3 <xsl:attribute name="value">Content</xsl:attribute> 4 5 will output 6 7 <input type="text" value-"Content" name="sharesLook" onclick="this.value=''" >
1 2 <xsl:if test="position() < 4"> 3 Records 4 </xsl:if>
1 2 <xsl:choose> 3 <xsl:when test="stuff = '' "> 4 <div>No data available</div> 5 </xsl:when> 6 <xsl:otherwise> 7 <div><xsl:value-of select="stuff_alternative"/></div> 8 </xsl:otherwise> 9 </xsl:choose>
1 2 <xsl:choose> 3 <xsl:when test="hour < 12"><xsl:value-of select="hour" />:<xsl:value-of select="format-number(min,'00')" /> AM</xsl:when> 4 <xsl:when test="hour = 12"><xsl:value-of select="hour" />:<xsl:value-of select="format-number(min,'00')" /> PM</xsl:when> 5 <xsl:when test="hour > 12"><xsl:value-of select="hour - 12" />:<xsl:value-of select="format-number(min,'00')" /> PM</xsl:when> 6 </xsl:choose>
1 2 <xsl:variable name="x">;width:<xsl:value-of select="($Width) - 10"/>px</xsl:variable> 3 <!-- same variable for Firefox --> 4 <xsl:variable name="y">width:<xsl:value-of select="($Width) - 15"/>px!important</xsl:variable> 5 6 <div id="z> 7 <xsl:attribute name="style"> 8 <xsl:value-of select="$y" /> 9 <xsl:value-of select="$x" /> 10 </xsl:attribute> 11 </div> 12 13 The resulting HTML will look like this: 14 15 <div id="z" style="width:240px!important;width:245px">
1 2 <xsl:output method="xml" omit-xml-declaration="yes" encoding="us-ascii"/>