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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Element validation based on attribute value? XMLSchema +

[ Lists Home | Date Index | Thread Index ]


Jeni Tennison wrote:

> <xs:simpleType name="meters">
>   <xs:restriction base="length">
>     <xs:maxInclusive value="3" />
>   </xs:restriction>
> </xs:simpleType>
>
> <xs:simpleType name="feet">
>   <xs:restriction base="length"
>     <xs:maxInclusive value="9.84" />
>   </xs:restriction>
> </xs:simpleType>

This works well enough in the case where you only "want to validate the myElement
is always <= 3 meters (regardless of the unit of measure.....so it's less than
roughly 11 feet)" (which is exactly what Jeni responded to), but in more general
cases, I don't think it would be a great approach.

As fractions of feet aren't typically expressed as a decimal value, either the
user or a process will be relied on to convert 9' 10 5/8" (or whatever it is) to
9.84' and then back, when the user requires a value that they can find on a tape
measure. Further processing is then required to compare the metric and imperial
values. If I were the original poster, I'd be inclined to standardise the uom to
metric and do the conversions as required, even if that meant also storing the
equivalent imperial size to prevent possible rounding errors.

(Although I'm sure that Jeni could do a schema fragment that handled the
interaction of feet, inches, and all of the common fractions down to, say, 64ths,
I'm pretty sure that she won't bother - infact, those sorts of co-occurrence
constraints sound right up Schematron's alley...;-)

Feet and inches. Two good reasons that the civilised world adopted the metric
system.


--
Regards,

Marcus Carr                      email:  mrc@allette.com.au
___________________________________________________________________
Allette Systems (Australia)      www:    http://www.allette.com.au
___________________________________________________________________
"Everything should be made as simple as possible, but not simpler."
       - Einstein





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS