[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: "if-condition-return something" idiom : is it

Subject: Re: Re: "if-condition-return something" idiom : is it possible in XSLT 1 ?
From: "Kerry, Richard richard.kerry@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 16 Jun 2014 13:54:15 -0000
Re:  Re: "if-condition-return something" idiom : is it
"If you're stuck with XSLT 1.0, this is going to be painful,"
Yes, I know ....
"because XSLT 1.0 doesn't have regular expressions."
Yes, I know ....

"From what you're describing, this problem alone would make shifting to a 2.0
toolchain worthwhile."
It's DocBook, which is XSLT 1, so I don't (think I) have a choice.

"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 doesn't need to be a completely general solution.  I have a selection of
formats used in existing documents.  They are all UK so I don't need to worry
about UK/US number order.
Expressed as (very) pseudo-REs they are something like:
   "dd? MMM(M{0,6}).? (cc)?yy"
   "MMM(M{0,6}).? (cc)?yy"
   "dd?/mm?/(cc)?yy"
   "mm?/(cc)?yy"
(where d, m, c and y are numeric, M is alphabetic.  Calculations are done to
convert 2 digit years to 4 digit.)

"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."

I'll have a look at this but I'm not sure it's that different to what I'm
doing now, which is :
1.  See if it matches "dd? MMM(M{0,6}).? (cc)?yy" or "MMM(M{0,6}).? (cc)?yy".
If it doesn't,
2. see if it matches "dd?/mm?/(cc)?yy" or "mm?/(cc)?yy".

And that's the first instance of the if-condition-return idiom.

Uncertainly,
Richard.





________________________________________
From: Graydon graydon@xxxxxxxxx [xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
Sent: 16 June 2014 14:36
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Re: "if-condition-return something" idiom : is it possible
in XSLT 1 ?

On Mon, Jun 16, 2014 at 01:11:41PM -0000, Kerry, Richard
richard.kerry@xxxxxxxx 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.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.