Here is a simple example of how to do it. Suppose you have the following XML file
<timesheet>
<date>04072010</date>
</timesheet> and you apply the following stylesheet to it
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="date">
<xsl:element name="date">
<xsl:call-template name="formatdate">
<xsl:with-param name="datestr" select="."/>
</xsl:call-template>
</xsl:element>
</xsl:template>
<xsl:template name="formatdate">
<xsl:param name="datestr" />
<!-- input format ddmmyyyy -->
<!-- output format dd/mm/yyyy -->
<xsl:variable name="dd">
<xsl:value-of select="substring($datestr,1,2)" />
</xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($datestr,3,2)" />
</xsl:variable>
<xsl:variable name="yyyy">
<xsl:value-of select="substring($datestr,5,4)" />
</xsl:variable>
<xsl:value-of select="$dd" />
<xsl:value-of select="'/'" />
<xsl:value-of select="$mm" />
<xsl:value-of select="'/'" />
<xsl:value-of select="$yyyy" />
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet> The output from the transformation is
<?xml version="1.0"?>
<timesheet>
<date>04/07/2010</date>
</timesheet>