xml - xslt convert date, seperated node -
on xml have in level3
<incorporationdate> <ccyy>2016</ccyy> <mm>04</mm> <dd>21</dd> </incorporationdate>
now need display 21 april 2016
so try concat , use format-date error try format string.
<xsl:variable name="incorpdate"> <xsl:value-of select="concat(//a:identification/b:incorporationdate/c:dd,'/',//a:identification/b:incorporationdate/c:mm,'/',//a:identification/b:incorporationdate/c:ccyy)"/> </xsl:variable>
and
<xsl:value-of select="format-date($incorpdate, '[d] [mnn] [y0001]')" />
i try format-date on whole node
<xsl:value-of select="format-date(//a:identification/b:incorporationdate, '[d] [mnn] [y0001]')" />
i know simple xml/xslt it's not know, learn need change lot's of stylesheets. understanding.
create xs:date
, format that:
<xsl:template match="incorporationdate"> <xsl:value-of select="format-date(xs:date(concat(ccyy, '-', mm, '-', dd)), '[d] [mnn] [y0001]')"/> </xsl:template>
complete sample
<xsl:transform xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="incorporationdate"> <xsl:value-of select="format-date(xs:date(concat(ccyy, '-', mm, '-', dd)), '[d] [mnn] [y0001]')"/> </xsl:template> </xsl:transform>
Comments
Post a Comment