xsl-list
[Top] [All Lists]

Re: [xsl] Re: "if-condition-return something" idiom : is it possible in XSLT 1 ?

2014-06-16 08:36:12
On Mon, Jun 16, 2014 at 01:11:41PM -0000, Kerry, Richard
richard(_dot_)kerry(_at_)atos(_dot_)net scripsit:
What I am doing is writing a callable template which will give dates
in the form yyyy-mm (y and m numeric) when given dates in a variety of
formats including those with strings for months (dd MMM yy,
dd/mm/yyyy, mm/yy, and many others).  So the input is a single string
which needs to be tested against a number of different formats and
picked apart accordingly.  Perhaps I can partly pick it apart then put
the parts into a node-set and get a template called on that.

If you're stuck with XSLT 1.0, this is going to be painful, because XSLT
1.0 doesn't have regular expressions.

From what you're describing, this problem alone would make shifting to a
2.0 toolchain worthwhile.

In general, I've found that per-weird-input-format date management is
troubling, because there are so many and many of them overlap.  It's
worked better to define a year variable, which contains the
preference-order (meaning, your preference for what test to believe the
results of) attempt to extract a year value and with a default of "nope"
so failure can be detected, and then the same with the month.  The
template then checks for failure and if it can, returns the assembled
year-month pair composed in whatever format's appropriate.

-- Graydon
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>