473,394 Members | 1,878 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,394 software developers and data experts.

Schema: express that "@a present if and only if @b present", where @a, @b are attributes

Dear Masters of XML

As I'm new to XML Schema I dare to ask a possibly recurring
question: Given an element <elem> with two attributes @a and
@b. The attributes are bound by the condition, that either both
or none must be present, i.e.

<elem a="val_a" b="val_b"/> or <elem/>

is valid, whilst

<elem a="val_a"/> or <elem b="val_b"/>

is not valid. In other words, attribute @a is present if and
only if attribute @b is present. How to express this be means
of XML Schema?

Could I ask you for a hint? Is there an insider's tip concerning
XML Schema comparable to the Mulberry Biglist on XSLT? Thank you
very much.

Yours sincerely,

Ralf
Jul 20 '05 #1
5 1882
> As I'm new to XML Schema I dare to ask a possibly recurring
question: Given an element <elem> with two attributes @a and
@b. The attributes are bound by the condition, that either both
or none must be present,

That is not possible with W3C's xml schema.

Jesper

--
Jesper Zedlitz eMail : je****@zedlitz.de
Homepage : http://www.zedlitz.de
ICQ# : 23890711
PGP-Key : http://zedlitz.de/pub_key.asc
Jul 20 '05 #2
"Jesper Zedlitz" <jz*@informatik.uni-kiel.de> wrote in message
news:br**********@bossix.informatik.uni-kiel.de...
As I'm new to XML Schema I dare to ask a possibly recurring
question: Given an element <elem> with two attributes @a and
@b. The attributes are bound by the condition, that either both
or none must be present,

That is not possible with W3C's xml schema.


But it is trivial to do in RELAX NG.

Bob Foster
http://xmlbuddy.com/
Jul 20 '05 #3
Hallo Jesper and Bob

Thanks for you hints. I'll take a close look on
Relax NG. Isn't it astonishing that a task as
simple as this can't be mapped be means of XML
Schema?

Best regards,

Ralf Wahner
Jul 20 '05 #4
Ra*********@iwr.uni-heidelberg.de (Ralf Wahner) writes:
Hallo Jesper and Bob

Thanks for you hints. I'll take a close look on
Relax NG. Isn't it astonishing that a task as
simple as this can't be mapped be means of XML
Schema?


I guess XML Schema takes the database notion of attributes
more seriously than some vocabulary designers. One
characteristic of a design in which this kind of
co-constraint occurs is that the design is apparently
trying to write two different kinds of objects using
the same element type. Where I come from, it's often
regarded as a sign of weakness in the design.

But your mileage may vary.

-C. M. Sperberg-McQueen
World Wide Web Consortium

Jul 20 '05 #5
"C. M. Sperberg-McQueen" <cm****@acm.org> wrote in message
news:m2************@acm.org...
Ra*********@iwr.uni-heidelberg.de (Ralf Wahner) writes:
Hallo Jesper and Bob

Thanks for you hints. I'll take a close look on
Relax NG. Isn't it astonishing that a task as
simple as this can't be mapped be means of XML
Schema?


I guess XML Schema takes the database notion of attributes
more seriously than some vocabulary designers. One
characteristic of a design in which this kind of
co-constraint occurs is that the design is apparently
trying to write two different kinds of objects using
the same element type. Where I come from, it's often
regarded as a sign of weakness in the design.

But your mileage may vary.


My mileage varies so much on this point my odometer is spinning in both
directions! ;-}

On the one hand, the markup idiom where the presence or contents of an
attribute determines the remaining attributes and contents of an element is
very widely used. I can find dozens of use cases, but perhaps none would be
more convincing in this context but XML Schema, itself. To give just one
example, if an <element> element has a name attribute, it may have a type
attribute and/or type contents, but if it has a ref attribute it may have
neither. But XML Schema, the language, can't describe such a constraint.

On the other, I am always interested in improving my data analysis skills.
In the Eclipse IDE, for example, plug-ins are allowed to define arbitrary
extension points to which other plug-ins can connect and add capability. The
XML syntax for this is <extension point="name_of_extension_point"... The
remaining attributes and element contents are determined by the extension
points, which have widely varying and unpredictable requirements for
information from their extensions. How would someone who "takes the database
notion of attributes more seriously" have designed this?

(The designers of Eclipse might have appreciated this answer, as they, some
would say unwisely, chose to use XML Schema, which is incapable of modeling
the central construct of their plug-in manifest languge.)

Bob Foster
http://xmlbuddy.com/
Jul 20 '05 #6

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

Similar topics

4
by: Adie | last post by:
Hi, I wonder if anyone might lend me a brain. I have a stock database to build that covers over 1000 products, which might be said to exist in around 50 product families. Obviously, just to be...
4
by: Andrew | last post by:
Antony (4:26 PM) : Hello all ! I have a problem with XML schema. My XML document which I need to be validated can be one of the following two types: 1st type is
0
by: Olaf Meyer | last post by:
I'm wondering if I can also express uniquness constraints on attributes of objects that I have referenced from somewhere else. To be a bit more precise here a short and simple XML document. The...
3
by: Victor | last post by:
Hi, I have some sample XML and an XSD below I have written. The XSD almost does what I want. What I need is some way of enforcing that AT LEAST TWO of the attributes "TestAttribute" are "X". ...
2
by: Stewart Johnson | last post by:
Hey All - I'm stuck while trying to write a schema, hoping someone can provide me with a flash of inspiration. One of the elements I'm writing has two attributes, both of which are optional....
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
2
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to...
4
by: ashish.sadanandan | last post by:
Hi, I'm new to XML and just started reading some documentation on W3C compliant schemas recently. The XML file I'm generating is for an embedded application and so size is of extreme importance....
3
by: hammie | last post by:
I'm utterless clueless on how I can go about declaring in my schema that two attributes must contain different values, e.g. <mail to="" from="">Text</mail> How do I set the restriction in the...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.