I am new to xslt. so this might be a basic question. I am trying to convert a date received in xs:date format to DD-MON-YYYY
input received is :
<tns:receivedDate>2017-06-27</tns:receivedDate>
Output expected
<tns:receivedDate>27-JUN-2017</tns:receivedDate>
Thanks in advance
If you mean convert
YYYY-MM-DD
toDD-MMM-YYYY
, try:Demo: https://xsltfiddle.liberty-development.net/94rmq7k
In XSLT-1.0 you have to implement the transformation yourself - without the help of build-in functions.
So a solution could look like the following. It uses a data-island in the XSLT to map the month's names. I defined the
tns
namespace to behttp://towelie.namespace
.The sample XML:
The solution XSLT-1.0 stylesheet:
In this stylesheet the input date is dissected to three variables which are then recombined in the
xsl:value-of
applying an index to the data-island'smon
elements.The output:
Final comment:
An important advantage of this approach is that you can define the month's names as you like - with different lengths in different languages - i.e. JAN, Jan, January, Janvier, Januar, Enero, ...
And the data-island could be replaced by external XML files. For example, one for each language.