OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Combining float/string to specify value/units



> As for the RE pattern, any ideas where I can find one already defined
> for a float number?  Despite my previous assertion of an application
> fully under my control, I'd like to make sure my patterns match the
> official XML Schema functionality as much as possible including the INF,
> NaN, and the exponential notations.
>
> Is the concept of using primitive datatypes in RE pattern matching
> encoding under consideration for future versions of XML Schema?  It
> seems inefficient not to be able to reuse all those wonderful built-in
> validation rules even if they may only be useful when restricting a
> string-based derived datatype.

This may be a long shot by I think this is a valid solution which could help you.
First define a type with all your different datatypes. E.g

<xsd:simpleType name="myTypes">
  <xsd:restriction base="xsd:string">
   <xsd:enumeration value="seconds"/>
   <xsd:enumeration value="msecs"/>
   <xsd:enumeration value="mins"/>
   <xsd:enumeration value="%"/>
   <xsd:enumeration value="knots"/>
   <!-- Add whatever else types you want -->
  </xsd:restriction>
 </xsd:simpleType>

Then create a union datatype that is a union between myTypes and xsd:float.

<xsd:simpleType name="myUnion">
  <xsd:union memberTypes="xsd:float myTypes"/>
 </xsd:simpleType>

If you create an element of this type you can have values of type "23.45", "12"
(any float), "msecs", "mins" etc. Now create a list type of your defined union
type.

 <xsd:simpleType name="myList">
  <xsd:list itemType="myUnion"/>
 </xsd:simpleType>

and finally restrict the list type to only contain 2 elements.

<xsd:simpleType name="my2List">
  <xsd:restriction base="myList">
   <xsd:length value="2"/>
  </xsd:restriction>
 </xsd:simpleType>

An element (or attribute) declared using my2List as type should have content like
"23.34 msecs", "12 mins" etc. The only problem is that "mins msecs", "mins 12",
"12.3 23" will also be valid but maybe that's ok?

Cheers,
/Eddie