[NEWBIE] Restrictions on attributes

Discussion in 'XML' started by poematrix, Sep 6, 2004.

  1. poematrix

    poematrix Guest

    Hi group.

    When I declare an element <some-element name=...> are there any
    restrictions on how many times I may assign a value for one and the
    same attribute name? I.e. is it legal to define an XML element that
    will contain unlimited recurrences of one and the same attribute, such
    that the following element definition would pass as legal:
    <some-element attribute1="value 1" attribute1="value 2"
    attribute1="value 3" />
    with all three values defined for the same attribute1 being equally
    available? Certainly, I can implement a software that would support
    such construct, but is it legal, i.e. does it conform with XML specs?

    TIA,
    Joseph
     
    poematrix, Sep 6, 2004
    #1
    1. Advertising

  2. In article <>,
    poematrix <> wrote:

    ><some-element attribute1="value 1" attribute1="value 2"
    >attribute1="value 3" />


    No, attributes must be unique: see http://www.w3.org/TR/REC-xml/#uniqattspec

    -- Richard
     
    Richard Tobin, Sep 6, 2004
    #2
    1. Advertising

  3. poematrix wrote:


    > When I declare an element <some-element name=...> are there any
    > restrictions on how many times I may assign a value for one and the
    > same attribute name? I.e. is it legal to define an XML element that
    > will contain unlimited recurrences of one and the same attribute, such
    > that the following element definition would pass as legal:
    > <some-element attribute1="value 1" attribute1="value 2"
    > attribute1="value 3" />
    > with all three values defined for the same attribute1 being equally
    > available? Certainly, I can implement a software that would support
    > such construct, but is it legal, i.e. does it conform with XML specs?


    It is not possible to have several attributes with the same name, you
    would need to use a list of values for one attribute e.g.
    <some-element attribute="whatever whatelse">
    or use child elements e.g.
    <some-element>
    <value-list>
    <value>value 1</value>
    <value>value 2</value>
    ..
    </value-list>
    </some-element>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Sep 7, 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. Replies:
    0
    Views:
    515
  2. Dan Platton

    character restrictions in names

    Dan Platton, Aug 27, 2003, in forum: Java
    Replies:
    0
    Views:
    295
    Dan Platton
    Aug 27, 2003
  3. Replies:
    3
    Views:
    497
    Mike Rawlins
    Dec 10, 2003
  4. Replies:
    4
    Views:
    456
  5. Marc Hebert
    Replies:
    3
    Views:
    619
Loading...

Share This Page