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

Discussion in 'XML' started by Ralf Wahner, Dec 10, 2003.

  1. Ralf Wahner

    Ralf Wahner Guest

    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
     
    Ralf Wahner, Dec 10, 2003
    #1
    1. Advertising

  2. > 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 :
    Homepage : http://www.zedlitz.de
    ICQ# : 23890711
    PGP-Key : http://zedlitz.de/pub_key.asc
     
    Jesper Zedlitz, Dec 11, 2003
    #2
    1. Advertising

  3. Ralf Wahner

    Bob Foster Guest

    "Jesper Zedlitz" <-kiel.de> wrote in message
    news:br9gd5$6na$-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/
     
    Bob Foster, Dec 13, 2003
    #3
  4. Ralf Wahner

    Ralf Wahner Guest

    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
     
    Ralf Wahner, Dec 16, 2003
    #4
  5. -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
     
    C. M. Sperberg-McQueen, Dec 17, 2003
    #5
  6. Ralf Wahner

    Bob Foster Guest

    "C. M. Sperberg-McQueen" <> wrote in message
    news:...
    > -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/
     
    Bob Foster, Dec 24, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    7
    Views:
    684
    Scott Allen
    Apr 11, 2005
  2. =?Utf-8?B?Q2FybCBNLg==?=
    Replies:
    4
    Views:
    2,492
    sivlookingforu
    Aug 7, 2006
  3. Markus
    Replies:
    1
    Views:
    1,611
    Markus
    Nov 23, 2005
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,295
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    3
    Views:
    2,951
Loading...

Share This Page