I am creating a XSD schema to represent a key-value pair list. I would like to restrict keys to string (that is easy) but the values are allowed to be any XSD simple types (datetime, string, int…). However, I do want the values in the xml instance documents to be strongly typed, i.e., it should be explicitly declared if a value is datetime, integer, or string etc. Could some show an example how can I enforce explicit value typing?
You need an xsd:union which allows a simple type to be validated as the first type in the list to which it is valid (and ordering potentially a difference if you are using the PSVI):
<xsd:simpleType name="intOrDateOrBool"> <xsd:union memberTypes="xsd:integer xsd:date xsd:boolean"/> </xsd:simpleType>