Groups | Blog | Home
all groups > dotnet xml > april 2004 >

dotnet xml : Making sure an Element Group contains elements with either two attributes or one attribute



Anthony Williams
4/7/2004 1:52:40 PM
Hi all,

I'm trying to put together an XSD for an XML type I'm experimenting with.

I was just wondering whether it's possible for me to validate whether an
image element, which I've defined in my XSD, can be enforced to contain
either one named attribute, or two other named attributes.

My XML document will eventually look something like this:

<Vehicles>
<Vehicle>
<VehicleID>1</VehicleID>
<!-- Various other elements -->
<Images>
<Image
ImageURL="http://www.mywebsite.com/myvehicles/myvehicle.jpg" />
<Image Filename="myvehicle.jpg"
ImageData="1b549c8d0a8099809f7818927409b078a0707..." />
</Images>
<!-- Various other elements -->
</Vehicle>
</Vehicles>

My question:

Is there a way to force an Image element in the Images element to contain
either:

Just an ImageURL attribute
or
A Filename attribute and an ImageData attribute

--
Kind regards,
Anthony Williams

v-kevy NO[at]SPAM online.microsoft.com
4/8/2004 12:50:38 PM
Hi Anthony,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to define 2 attributes in an
XSD, and force an element to contain either of them. If there is any
misunderstanding, please feel free to let me know.

As far as I know, this cannot be defined in XSD. However, we can put the
two attribute values in one, and use another attribute to identify the type
of the value attribute. The type attribute can be an enumerative value to
choose from ImageURL and FileName.

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Anthony Williams
4/8/2004 2:20:56 PM
Hi Kevin,

Thanks for the advice. We've gone down a seperate route with the XSD now due
to this. We've chosen to have three attributes, of which there must be at
least one.

We're also considering using a DTD instead of XSD.

Thanks anyway!

Kind regards,
Anthony Williams

[quoted text, click to view]

v-kevy NO[at]SPAM online.microsoft.com
4/9/2004 8:45:34 AM
Hi Anthony,

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
AddThis Social Bookmark Button