format-date

Questions about XML that are not covered by the other forums should go here.
tAnd
Posts: 5
Joined: Thu Dec 20, 2018 1:27 pm

format-date

Post by tAnd »

Hello

I have created a 1.0 stylesheet but i need the IssueDate to be in the form of YYYY-MM-DD. Now it is YYYYMMDD.
I have tried using

Code: Select all


<xsl:template match="IssueDate">
<td>
<xsl:value-of select="format-date(.,'[Y0001]-[M01]-[D01]')"/>
</td>
</xsl:template>
but it doesent work.

Anyone who knows what to do?
Thank you in advance.
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: format-date

Post by Radu »

Hi,

I'm not sure what you mean by "it does not work" but "format-date()" is an XSLT 2.0 function:

https://www.w3.org/TR/xslt20/#function-format-date

so you cannot use it in an XSLT 1.0 stylesheet.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tAnd
Posts: 5
Joined: Thu Dec 20, 2018 1:27 pm

Re: format-date

Post by tAnd »

Yes i figured that out. But the question is then - how should i do it in xslt 1.0?
Radu
Posts: 9049
Joined: Fri Jul 09, 2004 5:18 pm

Re: format-date

Post by Radu »

Hi,

You need to do it the hard way using substring-before, substring-after and so on.
I found a stackoverflow post about this:

https://stackoverflow.com/questions/164 ... n-xslt-1-0

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply