Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Schema: express that "@a present if and only if @b present", where @a, @b are attributes

Reply
Thread Tools

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

 
 
Ralf Wahner
Guest
Posts: n/a
 
      12-10-2003
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
 
Reply With Quote
 
 
 
 
Jesper Zedlitz
Guest
Posts: n/a
 
      12-11-2003
> 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 : http://www.velocityreviews.com/forums/(E-Mail Removed)
Homepage : http://www.zedlitz.de
ICQ# : 23890711
PGP-Key : http://zedlitz.de/pub_key.asc
 
Reply With Quote
 
 
 
 
Bob Foster
Guest
Posts: n/a
 
      12-13-2003
"Jesper Zedlitz" <(E-Mail Removed)-kiel.de> wrote in message
news:br9gd5$6na$(E-Mail Removed)-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/


 
Reply With Quote
 
Ralf Wahner
Guest
Posts: n/a
 
      12-16-2003
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
 
Reply With Quote
 
C. M. Sperberg-McQueen
Guest
Posts: n/a
 
      12-17-2003
http://www.velocityreviews.com/forums/(E-Mail Removed)-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

 
Reply With Quote
 
Bob Foster
Guest
Posts: n/a
 
      12-24-2003
"C. M. Sperberg-McQueen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (E-Mail Removed)-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/


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'classmethod' object has only read-only attributes Thomas Guettler Python 1 11-25-2009 02:30 PM
some operations present only for list<T> subramanian100in@yahoo.com, India C++ 4 02-07-2008 09:57 AM
OS present but not present. XPD NZ Computing 4 04-11-2007 11:22 PM
How to create hyperlink that appears only if the target file is present? The Dana's HTML 5 02-05-2005 11:02 PM
How to create hyperlink that appears only if the target file is present? The Dana's Javascript 3 02-05-2005 01:42 AM



Advertisments