xml - xsd:dateTime with specific precision -
an xsd work has element like:
<xsd:element name="tdlordertimestamp" type="xsd:datetime" minoccurs="0"/>
but i'm being told system requires 3 decimal points of precision on seconds. allowed xsd:datetime
, not required it.
we requiring:
<tdlordertimestamp>2015-05-12t18:58:02+00:00</tdlordertimestamp>
we should requiring:
<tdlordertimestamp>2015-05-12t18:58:02.123+00:00</tdlordertimestamp>
what's simplest way specify requirement in xsd? ideally, i'd stick close xsd:datetime
, iso8601's other idioms , idiosyncrasies possible.
a simple solution defining new simple type extends xsd:datetime , adds pattern restriction indicating value must contain dot followed 3 digits. example:
<xsd:simpletype name="datetimewithprecision"> <xsd:restriction base="xsd:datetime"> <xsd:pattern value=".*\.\d{3}.*"/> </xsd:restriction> </xsd:simpletype>
you can adapt pattern other desired datetime formats if want.
Comments
Post a Comment