HighTechTalks DotNet Forums  

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

Dotnet XML microsoft.public.dotnet.xml


Discuss Making sure an Element Group contains elements with either two attributes or one attribute in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Anthony Williams
 
Posts: n/a

Default Making sure an Element Group contains elements with either two attributes or one attribute - 04-07-2004 , 08:52 AM






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



Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default RE: Making sure an Element Group contains elements with either two attributes or one attribute - 04-08-2004 , 08:50 AM






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."


Reply With Quote
  #3  
Old   
Anthony Williams
 
Posts: n/a

Default Re: Making sure an Element Group contains elements with either two attributes or one attribute - 04-08-2004 , 09:20 AM



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

"Kevin Yu [MSFT]" <v-kevy (AT) online (DOT) microsoft.com> wrote

Quote:
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."




Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: Making sure an Element Group contains elements with either two attributes or one attribute - 04-09-2004 , 04:45 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."


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.