[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Element validation based on attribute value? XMLSchema +
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@a... ___________________________________________________________________ Allette Systems (Australia) www: http://www.allette.com.au ___________________________________________________________________ "Everything should be made as simple as possible, but not simpler." - Einstein
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|