[Home] [By Thread] [By Date] [Recent Entries]
Hi, Risheng Lin wrote: 1. Is there any way to represent an array?You can't specify these kinds of constraints with W3C XML Schema. However, Schematron is very good at this an can easily be integrated with XML Schema. See http://www.xfront.com/ExtendingSchemas.html for more details. 2. My second question is about type choice. Below is part of my schema:I'm not sure this will work but you can try to create your own datatype that is a union between float and double like this: <xsd:simpleType name="float_double">
Then declare your element Data to be of this type: <xsd:element name="Data" type="float_double" minOccurs="1" maxOccurs="unbounded"/> In your instance document you can then use the xsi:type attribute to specify which type you use: ...
However, I'm not sure this will work. The spec says [1]: "The order in which the ·memberTypes· are specified in the definition (that is, the order of the <simpleType> children of the <union> element, or the order of the QNames in the memberTypes attribute) is significant. During validation, an element or attribute's value is validated against the ·memberTypes· in the order in which they appear in the definition until a match is found. The evaluation order can be overridden with the use of xsi:type." I'm not sure if you can just override the evaluation order or if you can actually specify the specific type within the union. I.e will the validator continue to check the the above example for conformance to the xsd:float type if the xsd:double check fails? Cheers,
[1] http://www.w3.org/TR/xmlschema-2/#union-datatypes
|

Cart



