Subject: Re: [xsl] dateTime format string, Anyone developed an rng definition? From: Dave Pawson <davep@xxxxxxxxxxxxx> Date: Wed, 03 Feb 2010 16:47:26 +0000 |
http://www.w3.org/TR/xslt20/#format-date defines format-dateTime( $value as xs:dateTime?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $country as xs:string?) as xs:string? The picture string is fairly regular. Has anyone produced a relaxng expression which captures it please?
I hadn't, but just took a crack at it. I think
xsd:token { pattern = "(([^\[\]]|\[\[|\]\])+|\[[YMDdFWwHhPmsfZzCE](((\p{Nd}|\p{Nl}|\p{No}|\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo})+|N|n|Nn)[to]?)?(,([0-9]+|\*)(-[0-9]+|\*)?)?\])+" }
does the job, (Note xsd:token, not xsd:string, as I wrote this presuming the string to be matched has already been run through normalize-space().) Not very well tested. See http://dev.stg.brown.edu/staff/Syd_Bauman/temp/format-dateTime-picture-validate.tgz.
I took note from John Cowan that comments can be used Syd! I'm ignoring certain values (simplicity).
<element name='doc'> <oneOrMore> <element name='dateTime'> <data type='string'> <param name='pattern'><!-- Year -->(\[Y(01|0001)?\][^\[]?)<!-- Month -->(\[M(1|01)?\]?[^\[]?)<!-- Day -->(\[D(1|01)?\])?<!-- Hour -->(T\[H[01]{0,2}\]:<!-- Minutes -->\[m(1|01)?\]:<!-- Seconds -->\[s(1|01)?\]\.<!-- decimal seconds -->\[f(1|01|001)?\])?</param> </data> </element>
<doc> <dateTime>[Y0001]-[M01]-[D]</dateTime> <dateTime>[Y]@[M]@[D]</dateTime> <dateTime>[Y0001]-[M01]-[D1]</dateTime> <dateTime>[Y]-[M1]-[D1]</dateTime> <dateTime>[Y]-[M]-[D]T[H]:[m1]:[s].[f]</dateTime> <dateTime>[Y][M]-[D01]T[H01]:[m01]:[s01].[f001]</dateTime> <dateTime>[Y][M]-[D01]T[H01]:[m01]:[s01].[f001]</dateTime>
<!-- Errors --> <dateTime>[Y100][M][D]T[H]:[m]:[s].[f]</dateTime> <dateTime>[Y][M100][D]T[H]:[m]:[s].[f]</dateTime> <dateTime>[Y][M][D10]T[H]:[m]:[s].[f]</dateTime> <dateTime>[Y][M][D10]T[H]:[m10]:[s].[f]</dateTime> <dateTime>[Y]-[M]-[D01]T[H01]:[m01]:[s0001].[f001]</dateTime>
YWw for 'Two thousand and ten' MNn for December Dlo for 31st DWo for twentieth
Its for a graph X axis, using dates. As you see, we only need the Y M D H m s parts which makes it a little easier.
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dateTime format string, A, Syd Bauman | Thread | [xsl] COCOMO project cost metrics f, Justin Johansson |
[xsl] dynamically generate value fo, Mario Madunic | Date | Re: [xsl] are all strings in a sequ, ac |
Month |