Project

Profile

Help

format-date problem

Added by Anonymous over 18 years ago

Legacy ID: #3624136 Legacy Poster: Yannick (efolia)

Hi, I'm having a little problem figuring out this one. Whenever I write: <xsl:value-of select="format-date(current-date(),'[Y01]-[M01]-[D01]')"/> The goal rather simple: formatting today's date. However, I get this as an output: [Language: en]2006-03-11 Obviously, the Language attribute shouldn't be there. I can sidestep this problem with a regex, it but I'd rather not add code to the XSL page for such a simple function. Is that a little bug or just some undocument feature or high level setting I'm not aware of? BTW, I'm doing relatively complex processing with Saxon8 and most everything else works flawlessly so far: thanx a lot for the great job! I'm using Saxon8.7J under Windows XP running the latest version of Java VM. Yannick


Replies (2)

RE: format-date problem - Added by Anonymous over 18 years ago

Legacy ID: #3625155 Legacy Poster: Michael Kay (mhkay)

Interesting one. The language argument (the third argument of format-date()) defaults to the language of the default Java locale. Presumably in your case this is not English. If there is no localization of format-date installed for that language, format-date falls back to English, adding the string [Language: en] as required by the spec, to indicate that the language used is not the one requested. You can fix this by changing your call to format-date(current-date(),'[Y01]-[M01]-[D01]', 'en', (), ()) I'll have a think, though, about changing the design to avoid this problem occurring. Michael Kay Saxonica

RE: format-date problem - Added by Anonymous over 18 years ago

Legacy ID: #3625333 Legacy Poster: Yannick (efolia)

Hi and thank you very much. It worked. I was convinced I had tried that solution before asking for advice, but I guess I must have applied it wrong: the 3-way logic (input/system/output) behind language switching is quite interesting but a little twisted conceptually. I don't see a solution to this problem except for implementing a mechanism that disables all the output that is not explicit -- for this problem is akind to including system error messages in the xsl output. For those of use who keep to XML and who design to purposely limit further processing by a programming language to a minimum, it would make lots of sense. My goal is to keep the solutions I design as close to pure XML as possible, thus avoiding all the traps and pitfalls that the programming solutions eventually lead to. Actually, this has only been possible since the release of XSLT 2.0 and its Saxon 8.7 implementation. Thanks again. :) Yannick

    (1-2/2)

    Please register to reply