Hi,
I have a question regarding XML and XSD validation.
This question came from a discussion with a colleage, and so here I am trying to figure out who will end up victorious and by the lunch
Let's go then!
I have a possible XML message, like:
<root>
<name>Someone Here</name>
<email>someone.here@gmail.com</email>
</root>
Then I have the following extract from XSD, for the "email" element:
<xs:element name="email" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Here I defined in my XSD that the "email" element is optional, and it's type is "xs:string" with a minimum of 1 char.
Now the way I see it, I can simply throw:
<root>
<name>Someone Here</name>
</root>
and it will comply with XSD schema, but if I send:
<root>
<name>Someone Here</name>
<email></email>
</root>
it will fail miserably, correct?
My colleage told me about a possibility to configure it as "qualified" or "unqualified" element, which would allow me to receive "<email></email>" without breaking when checked against XSD.
I have serious doubt that it is possible, since the XSD defines that it is an optional element, and WHEN it EXISTS, it MUST be a String with minimum 1 char.
So am I correct? Or am I correct?
I hope so ... or if not, please point me the direction to read info about it.
Many Thanks
I have a question regarding XML and XSD validation.
This question came from a discussion with a colleage, and so here I am trying to figure out who will end up victorious and by the lunch
Let's go then!
I have a possible XML message, like:
<root>
<name>Someone Here</name>
<email>someone.here@gmail.com</email>
</root>
Then I have the following extract from XSD, for the "email" element:
<xs:element name="email" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Here I defined in my XSD that the "email" element is optional, and it's type is "xs:string" with a minimum of 1 char.
Now the way I see it, I can simply throw:
<root>
<name>Someone Here</name>
</root>
and it will comply with XSD schema, but if I send:
<root>
<name>Someone Here</name>
<email></email>
</root>
it will fail miserably, correct?
My colleage told me about a possibility to configure it as "qualified" or "unqualified" element, which would allow me to receive "<email></email>" without breaking when checked against XSD.
I have serious doubt that it is possible, since the XSD defines that it is an optional element, and WHEN it EXISTS, it MUST be a String with minimum 1 char.
So am I correct? Or am I correct?
I hope so ... or if not, please point me the direction to read info about it.
Many Thanks
