Hello!
I have a situation where an element in the XML-file can be of two different types in the XSD.
What I want to do is first to validate the entered value to the more strict type (if it's a person that fills out the form) and if that doesn't pull through, validate it to the lesser strict type (if it's an organization that fills out the form), otherwise let the validation fail if it doesn't validate at all.
So this is basically it:
<xsd:complexType name="ForminfoType"> `
<xsd:sequence>
<xsd:element name="formname" type="xsd:string" />
<xsd:element name="timestamp" type="xsd:dateTime" />
<xsd:element name="sender" type="PersonType" minOccurs="0" />
<xsd:element name="receiver" type="OrganizationType" minOccurs="0" />
<xsd:element name="signature" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
What the PersonType declares is basically a 12-digit number constructed according to a specific pattern. What the Organization type declares is basically just a 10-digit number.
So what I logically would like to do is to put this:
<xsd:element name="sender" type="OrganizationType" minOccurs="0" />
into the sequence, but you can't have two elements with the same name and different types. So I reckon I must solve it in some other way.
What I have found was this: http://xsd.stylusstudio.com/2007Oct/post05003.htm
Which is pretty much what I want to do, but I'm not sure it's possible. Has anyone got any further ideas on how to solve this?
Thanks in advance.