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 » Tue Jan 15, 2019 5:23 pm

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: 6433
Joined: Fri Jul 09, 2004 5:18 pm

Re: format-date

Post by Radu » Wed Jan 16, 2019 4:03 pm

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 » Wed Jan 16, 2019 4:22 pm

Yes i figured that out. But the question is then - how should i do it in xslt 1.0?

Radu
Posts: 6433
Joined: Fri Jul 09, 2004 5:18 pm

Re: format-date

Post by Radu » Wed Jan 16, 2019 4:25 pm

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