Been trying to format the text to display as DD-MM-YYYY when pulled from XML to XSLT 1.0, since I know it has to be laid out as YYYY-MM-DD within XSD/XML when using xs:date whic
In XSLT 2.0 you can use tokenize to split the string and then just using xsl:for-each
and xsl:sort
to reverse it. (I don't have an XSLT2.0 engine right now, but this is pretty close to what you'll need).
In XSLT 1.0, you do it using... recursion!
Here is the crux of it, this takes a date, and then searches for the string before and after the first hyphen (-
). Normally, you'd have the substring-before
come after the processing of the subtring-after
to preserve the order, but here we switch them to ultimately reverse the ouput.
-
Below is the complete template that will reverse the date for you based on your above XML document.
-
You'll need to change this:
To this: