473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
Nov 12 '05 #1
3 1129
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."

Nov 12 '05 #2
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-****@online.microsoft.com> wrote in message
news:R4**************@cpmsftngxa06.phx.gbl...
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."

Nov 12 '05 #3
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."

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jean-Christophe Michel | last post by:
Hi, In a complex merging of two (non ordered) xml files i need to keep track of the elements of the second tree that were already merged with first tree, to copy only unused elements at the end....
3
by: Pablo Gomes Ludermir | last post by:
Hello, I have the following case that I am trying to put in XML Schema. I have the classes HelpItem, Document and Message that work as follows: One HelpItem contains several Document and...
1
by: middletree | last post by:
For an ASp Intranet app, I have some code that should work, but I am not able to make it happen for some reason, after spending considerable time on this. I am pretty thick when it comes to...
8
by: Neil Zanella | last post by:
Hello, I would like to know why the W3C decided not to make the following valid XHTML: <input checked type="radio" name="foo" value="bar" />FooBar forcing people to write the following to...
2
by: Lisa | last post by:
I have to work with an existing xml where there is a root element and all other elements are children of the root (in other words there is no nesting or hierarchy), e.g. <myroot> <A>adata</A>...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
9
by: Philipp | last post by:
Hello. OK I know this is the most asked question in XML (it says in some tutorial), but still. Please give me your insight on this (as I'm a newbie). I want to store parameters for a programm in...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.