| Topic | xsl template : change the display format of a date |
| Output | DD/MM/YYYY |
| Step | Description |
| 1 | Create the main transformation template
<xsl:template name="Tz_Date" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" />
<script type="text/javascript">
var sdate = '<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" />';
if (sdate.length > 6)
document.write(sdate.split('/')[1] + '/' + sdate.split('/')[0] + '/' + sdate.split('/')[2]);
</script>
</xsl:template>
|
| 2 | Create template that match all the fields who need to be transformed
<xsl:template name="Format_Begin_x0020_Date" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Begin_x0020_Date']" mode="DateTime_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:param name="thisNode" select="."/>
<xsl:call-template name="Tz_Date"><xsl:with-param name="thisNode" select="$thisNode"/></xsl:call-template>
</xsl:template>
|
| 3 | Repeat step 2 for each field match needed |
No comments:
Post a Comment