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

RE: Different results of format-date() when using empt

Subject: RE: Different results of format-date() when using empty seq. or omitting args for lang/cal/country args
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 2 Oct 2006 15:04:28 +0100
empt download
> While trying to output a value as ISO calendar using a 
> default language, I came across a little niche in the xslt 
> specification that I find hard to interpret right. My problem 
> is this: when I want to output as ISO calendar, I have to 
> provide the last three arguments for format-date(). 
> The spec says that I can use the empty sequence to use for 
> the default value, which value is implementation-defined. 
> Fair enough. But when I use the empty sequence for language, 
> the processor defaults to language X and outputs with 
> [Language: en] somedate, saying in fact that it does not 
> support the default language requested! Am I missing 
> something, or is this is a processor dependent bug?

Saxon is taking the default from the Java locale, and then falling back to
English if you haven't installed a date localisation for that locale. It
would probably be more sensible to collapse these two steps, which would
mean you didn't get the [Language: en] in the output.

The current behaviour of Saxon is conformant with the spec, but there are
other conformant behaviours that might be more user-friendly.

Michael Kay
http://www.saxonica.com/

> 
> My hunch is that the processor takes the current language 
> setting from system properties, which is, likely, to vary 
> from system to system (in my case 'nl'). What I expected it 
> to, is to default to a fixed language code, namely 'en' (or 
> any other for that matter). That way, the following two 
> statements would be equal:
> 
> Ex 1) format-date(current-date(), '[D1]/[Y1]') Ex 2) 
> format-date(current-date(), '[D1]/[Y1]', (), (), ())
> 
> Output ex. 1) 10/2006
> Output ex. 2) [Language: en] 10/2006
> 
> In some way, this feels like violating the specs, but I 
> cannot be sure of that. The specs say: "When any of these 
> arguments is omitted or is an empty sequence, an 
> implementation-defined default value is used."
> 
> You can only omit all three last arguments at once. I expect 
> the "default value" to be the same all the time, instead 
> being different for 'omitting' and 'empty sequence'.
> 
> I would like to use the following statement (3), for logging 
> my stuff to some system. Unfortunately I have to resort 
> statement (4), to get rid of the [Language: en] part in the 
> output. But specifying the language does not feel right, 
> because I want the default to be used, to be sure the 
> processor can support the default (but it doesn't).
> 
> Ex 3) format-date(current-date(), '[D1] [MNn] [Y1], (), 
> 'ISO', ()) Ex 4) format-date(current-date(), '[D1] [MNn] 
> [Y1], 'en', 'ISO', ())
> 
> Output ex 3) [Language: en]2 October 2006 Output ex 4) 2 October 2006
> 
> Does anybody has some experience with this with other processors? 
> Anybody any thoughts on this or on how I should interpret the 
> particular part of the specs? Is the spec indeed open to 
> implement for different outputs for (1) and (2), or is that 
> an error in the processor?
> 
> I tested with Saxon 8.7.1
> 
> Cheers,
> Abel Braaksma

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.