Re: custom date type in xml schema

Hanna,

      First, ask yourself why you care how the characters representing a
date are coded in an attribute or element in an XML instance document.
There are reasons to think you may regret doing this.

      In the future, when improved XML Query tools are available, you may
regret that you didn't use the standard coding.  It should not be hard,
whenever date is presented to a user, to convert to the coding most
familiar to your user community using facilities of XSLT (for example), or
tools that will present and retrieve XML data from users based on schema
types connected with the forthcoming W3C XForms specifications.

      Secondly, should you decide that you have a compelling reason to have
your own coding, the pattern facet has to be defined using a regular
expression language which is described at:
 http://www.w3.org/TR/xmlschema-0/#regexAppendix    for an overview
 http://www.w3.org/TR/xmlschema-2/#regexs          for all the details
Therefore, you would code something like:
 <pattern value="NN\-NN\-NNNN"/>

            Good luck,
            Bob Schloss

XML/XSL Transformational Systems
IBM Thomas J. Watson Research Center
Yorktown Heights, NY, USA





                                                                                                                                      
                      "Hanna"                                                                                                         
                      <lhnhanna@hotmail        To:       <xmlschema-dev@w3.org>                                                       
                      .com>                    cc:                                                                                    
                      Sent by:                 Subject:  custom date type in xml schema                                               
                      xmlschema-dev-req                                                                                               
                      uest@w3.org                                                                                                     
                                                                                                                                      
                                                                                                                                      
                      02/05/2003 11:36                                                                                                
                      PM                                                                                                              
                                                                                                                                      




Dear all,
         I would like to ask how to customize date type such as MM-DD-CCYY,
or YY/MM/DD instead of the default CCYY-MM-DD in schema.
        I have tried the following but the validation result is that the
date value is invalid.
        Please help.
xsd:
<simpleType name='mydatetype'>
        <restriction base='date'>
            <pattern value='MM-DD-CCYY'/ >
        </restriction>
</simpleType>
xml:
      <birthday>10-29-2002</birthday>
Regards,
Hanna

Received on Thursday, 6 February 2003 13:57:34 UTC