XSLT Function AddYears

Adds a specified number of years to a date.

NAMESPACE

xmlns:AS="http://schema.advantages.cz/AsapFunctions"

SYNTAX

string AddYears(string date, string years)

PARAMETERS

Name Description
date Date to which years will be added.
years Number of years to add (if negative, years will be deducted).

REMARKS

If the date has a time part, the time is not touched.

EXAMPLE

This example adds 1 year to a source date.
Source XML

<ROOT> 
    <test date="2012-03-23"/> 
</ROOT>

Stylesheet

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:AS="http://schema.advantages.cz/AsapFunctions" 
    xmlns:date="http://exslt.org/dates-and-times" 
    exclude-result-prefixes="AS date"> 
    <xsl:template match="/"> 
        <test test="{AS:AddYears(/ROOT/test/@date, 1)}"/> 
    </xsl:template> 
</xsl:stylesheet>