Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Time without Seconds

From: "Rowan Sylvester-Bradley" <rowan@-----------------.--->
To: <xmlschema-dev@--.--->
Date: 10/13/2008 1:49:00 PM
Pete,

Many thanks, that works fine. I ended up with the following, which accepts 
times with or without seconds:

<xsd:simpleType name="time_hh_mm">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[0-1][0-9]:[0-5][0-9]"/>
    <xsd:pattern value="[0-1][0-9]:[0-5][0-9]:[0-5][0-9]"/>
    <xsd:pattern value="2[0-3]:[0-5][0-9]"/>
    <xsd:pattern value="2[0-3]:[0-5][0-9]:[0-5][0-9]"/>
  </xsd:restriction>
</xsd:simpleType>

Rowan

----- Original Message ----- 
From: "Pete Cordell" <petexmldev@c...>
To: "Rowan Sylvester-Bradley" <rowan@s...>; 
<xmlschema-dev@w...>
Sent: Monday, October 13, 2008 9:30 AM
Subject: Re: Time wihtout Seconds


>
> ----- Original Message From: "Rowan Sylvester-Bradley"
>
>> How do I write a schema that will validate an element containing a
>> time in the format hh:mm (without any seconds)? I'm trying to write
>> a schema for an existing XML file that's generated by a piece of
>> software which I have no access to, so I can't just add the seconds...
>
> In that case you probably want to have a base type of an xs:string and 
> then restrict it using an xs:pattern facet.  Something like:
>
> <xs:simpleType name="myTime">
> <xs:restriction base="xs:string">
>  <xs:pattern value="[0-2][0-9]:[0-5][0-9]"/>
> </xs:restriction>
> </xs:simpleType>
>
> Or possibly even better:
>
> <xs:simpleType name="myTime">
> <xs:restriction base="xs:string">
>  <xs:pattern value="[0-1][0-9]:[0-5][0-9]"/>
>  <xs:pattern value="2[0-3]:[0-5][0-9]"/>
> </xs:restriction>
> </xs:simpleType>
>
> (I'm pretty sure the pattern facets have an OR type relationship rather 
> than an AND type relationship.  I'm sure someone will correct me if I'm 
> wrong.)
>
> HTH,
>
> Pete Cordell
> Codalogic Ltd
> Interface XML to C++ the easy way using XML C++
> data binding to convert XSD schemas to C++ classes.
> Visit http://www.codalogic.com/lmx/ for more info


From noah_mendelsohn@u... Mon Oct 13 20:28:15 2008
Received: from maggie.w3.org ([193.51.208.68])
	by fr


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent