XSD Help
I was fooling around a few days ago, writing an Xml Schema for an XML configuration file for a personal project I'm working on, and ran into something I don't know how to describe in XSD.... well, actually I'm not even sure it is entirely possible.
Basically, I wanted to have a section of the file contain something like this:
<condition>
<from>some string</from>
<to>some other string</to>
</condition>
The problem was that as I wanted it to be, the condition element could conain either the from element, the to element, or both, but at least one of the had to be present.
So, obviously, I know how to use minOccurs and maxOccurs, but that would only allow me to specify the frst condition, but not make it so that at least one of them was present. Neither did I find a way to do it using xsd:choose and friends.
So, is it possible to do, and if so, how? I'd appreciate any tips you could offer (and a pointer to the XSD spec section that makes it possible, if you're able to provide one)!






This is untested but I think it will get you what you want:
<xsd:choice>
<xsd:sequence>
<xsd:element ref=”from” />
<xsd:element ref=”to” minOccurs=”0″ />
</xsd:sequence>
<xsd:element ref=”to” />
<xsd:choice>
Oops.
<xsd:choice>
<xsd:sequence>
<xsd:element ref=”from” />
<xsd:element ref=”to” minOccurs=”0″ />
</xsd:sequence>
<xsd:element ref=”to” />
</xsd:choice>
Sir,
Actually, I have similar kind of problem.
I am trying to bulkload a XML file into the database using XSD.
But I require a condition.
The tags are as follows
<SpecialTopic selected=”False” SpecialTopicID=”1″ GrantNumberID= “1″ />
<SpecialTopic selected=”True” SpecialTopicID=”1″ GrantNumberID=”1″ />
I want to upload SpecialTopicID and GrantNumberID attribute of the tags based on the value of the
selected attribute.
If the value of the selected attribute is “True” then I want to bulk load SpecialTopicID and GrantNumberID otherwise I don’t.
I would greatly appreciate it if someone could help me with the xsd.
Thanks,
Bhisham Asnani