|
You can use the substring() function:
<xsl:template match="date">
<div>
<xsl:attribute name="class">date</xsl:attribute>
<xsl:value-of select="substring(text(), 9, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(text(), 6, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(text(), 1, 4)"/>
</div>
</xsl:template>
One word of caution, xs:date does allow more than four digits for the year, and an optional minus sign, so -1000000-02-14 (one millions years B.C.) is a valid xs:date and the above would not work. But you can always define your schema to force the date to fall within a specific range. For example:
<xs:element name="date">
<xs:simpleType>
<xs:restriction base="xs:date">
<xs:minInclusive value="0001-01-01"/>
<xs:maxInclusive value="9999-12-31"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Last edited by BrainJar; 02-01-2003 at 07:41 PM..
|