« Rethrowing Exceptions in C# | Main | XSD Resolved! »
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.
from
to
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.
minOccurs
maxOccurs
xsd:choose
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 theselected 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
Syndicate
About
Tomas Restrepo is a software developer located in Colombia, South America. His interests include .NET, Connected Systems, PowerShell and lately dynamic programming languages. More...
email: tomas@winterdom.com msn: tomasr@passport.com
Ads
Links
Categories
Statistics
Blogroll
Post Archive
Other
Copyright © 2002-2008, Tomas Restrepo.
Powered by: newtelligence dasBlog 2.1.8139.823