![]() |
| XSLT functions Xsltp.pl Perl XSLT parser supports the following functions boolean, concat, contains, count, current, document, false, file-name, last, gmtime, key, name, normalize-space, not, number, position, string, string-length, sum, system-property, starts-with, substring-after, substring-before, save-file, substring, time, true, translate. The system-property function is an interface to the environment variables. Examples, system-property( 'HTTP_ACCEPT_LANGUAGE'), system-property('DOCUMENT_ROOT') and so on. If a particular environment variable is undefined empty string is returned. The time function is a wrapper of Perl time function. The gmtime(integer expression?) function is a wrapper of Perl gmtime function. In node-set context, it returns the result tree fragment of the form <year>2004</year><month>1</month><day>28</day><hours>12</hours><minutes>30</minutes> <seconds>15</seconds><weekday>4</weekday><yearday>28</yearday> (weekday ranges 1-7, month ranges 1-12, yearday ranges 1-365(366)). In scalar context, it returns string "Wed Jan 28 12:30:15 2004". Example, <xsl:template name="time"> <xsl:for-each select="gmtime(time()+3*3600)"> <xsl:value-of select="year"/><xsl:text>-</xsl:text> <xsl:choose> <xsl:when test="month>9"> <xsl:value-of select="month"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(0,month)"/> </xsl:otherwise> </xsl:choose><xsl:text>-</xsl:text> <xsl:choose> <xsl:when test="day>9"> <xsl:value-of select="day"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(0,day)"/> </xsl:otherwise> </xsl:choose><xsl:text> </xsl:text> <xsl:choose> <xsl:when test="hours>9"> <xsl:value-of select="hours"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(0,hours)"/> </xsl:otherwise> </xsl:choose><xsl:text>:</xsl:text> <xsl:choose> <xsl:when test="minutes>9"> <xsl:value-of select="minutes"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(0,minutes)"/> </xsl:otherwise> </xsl:choose><xsl:text>:</xsl:text> <xsl:choose> <xsl:when test="seconds>9"> <xsl:value-of select="seconds"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat(0,seconds)"/> </xsl:otherwise> </xsl:choose></xsl:for-each> </xsl:template> |