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

Re: dateTime format string, Anyone developed an rng d

Subject: Re: dateTime format string, Anyone developed an rng definition?
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Wed, 03 Feb 2010 16:47:26 +0000
Re:  dateTime format string
On 03/02/10 15:26, Syd Bauman wrote:
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).

So far I've generated

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


with test data of


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

</doc>

and exclusions of

   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.

I thought someone may have done it already

Thanks though. Appreciated.




regards


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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.