Complex attribute defaults?

Discussion in 'XML' started by Robert William Vesterman, Dec 19, 2004.

  1. Is there a way to say, in a DTD things like:

    (1) The default value of attribute X is the value of attribute Y?

    (2) The default value of attribute X is the value of attribute Y
    appended by the text "BLAH"?

    (3) The default value of attribute X is "BLAH" if attribute Y has
    value "BLING", or "BOING" otherwise?

    (4) The default value of attribute X is "BLAH" if attribute Y is
    present, or "BOING" otherwise?

    Or various other possibilities beyond the simple "the default value is
    such-and-such and that's all there is to it"?

    If I need such concepts, and it's not possible, obviously I have to do
    them at the application level, and pretend at the XML level that
    they're just "#IMPLIED". Is that somehow considered an invalid,
    incorrect, impure, evil, or otherwise negative thing to do?

    Thanks,

    Bob Vesterman.
     
    Robert William Vesterman, Dec 19, 2004
    #1
    1. Advertising


  2. > Is there a way to say, in a DTD things like:
    > ...

    No

    > If I need such concepts, and it's not possible, obviously I have to do
    > them at the application level, and pretend at the XML level that
    > they're just "#IMPLIED". Is that somehow considered an invalid,
    > incorrect, impure, evil, or otherwise negative thing to do?


    It's the way life is. It's certainly not invalid, I leave others to
    judge harder concepts such as impurity or evil:)

    David
     
    David Carlisle, Dec 21, 2004
    #2
    1. Advertising

  3. Robert William Vesterman

    Peter Flynn Guest

    Robert William Vesterman wrote:

    > Is there a way to say, in a DTD things like:
    >
    > (1) The default value of attribute X is the value of attribute Y?


    In a *DTD*, yes, but only by hardcoding it

    <!ATTLIST foo X (a|b|c) "c" Y (c) "c">

    A default token list value must be a literal: it can't be a parameter
    entity, so it's not possible to hard-code it.

    But I find it hard to imagine a circumstance where you want to do this.
    Can you explain more? I think you mean that you want to do this in an
    XML document instance.

    > (2) The default value of attribute X is the value of attribute Y
    > appended by the text "BLAH"?


    The same answer.

    > (3) The default value of attribute X is "BLAH" if attribute Y has
    > value "BLING", or "BOING" otherwise?
    >
    > (4) The default value of attribute X is "BLAH" if attribute Y is
    > present, or "BOING" otherwise?


    No. You have to use a Schema if you want this level of validation.

    > Or various other possibilities beyond the simple "the default value is
    > such-and-such and that's all there is to it"?
    >
    > If I need such concepts, and it's not possible, obviously I have to do
    > them at the application level, and pretend at the XML level that
    > they're just "#IMPLIED". Is that somehow considered an invalid,
    > incorrect, impure, evil, or otherwise negative thing to do?


    No, just that DTDs were designed for TEXT documents, not DATA, so
    cross-validation of attribute values was not an issue, as it arises
    so rarely in normal text documents.

    ///Peter
    --
    "The cat in the box is both a wave and a particle"
    -- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
     
    Peter Flynn, Dec 31, 2004
    #3
    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. news.amnet.net.au
    Replies:
    1
    Views:
    604
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 13, 2004
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    790
    Stanimir Stamenkov
    Oct 25, 2005
  3. Robert Mark Bram
    Replies:
    0
    Views:
    716
    Robert Mark Bram
    Feb 4, 2007
  4. Kottiyath

    How complex is complex?

    Kottiyath, Mar 18, 2009, in forum: Python
    Replies:
    22
    Views:
    799
  5. kanpeter
    Replies:
    0
    Views:
    1,344
    kanpeter
    Oct 26, 2010
Loading...

Share This Page