unique attribute value

Discussion in 'XML' started by kanpeter, Oct 11, 2010.

  1. kanpeter

    kanpeter Guest

    Hi,

    How can I declare the xsd such that an element Fare will have an
    attribute of name "type" and each value of "type" can occur at most
    once?



    <Fare type="faretype1"/>
    <Fare type="faretype2"/>

    is valid in XML but not

    <Fare type="faretype1"/>
    <Fare type="faretype1"/>
    kanpeter, Oct 11, 2010
    #1
    1. Advertising

  2. kanpeter wrote:

    > How can I declare the xsd such that an element Fare will have an
    > attribute of name "type" and each value of "type" can occur at most
    > once?
    >
    >
    >
    > <Fare type="faretype1"/>
    > <Fare type="faretype2"/>
    >
    > is valid in XML but not
    >
    > <Fare type="faretype1"/>
    > <Fare type="faretype1"/>



    In the definition of the parent element of those "Fare" elements use
    <xs:unique name="unique-fare-type">
    <xs:selector xpath="Fare"/>
    <xs:field xpath="@type"/>
    </xs:unique>
    See http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness
    --

    Martin Honnen
    http://msmvps.com/blogs/martin_honnen/
    Martin Honnen, Oct 11, 2010
    #2
    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. James J. Foster
    Replies:
    0
    Views:
    525
    James J. Foster
    Aug 7, 2003
  2. Replies:
    1
    Views:
    4,270
    Joe Kesselman
    Aug 2, 2006
  3. Replies:
    8
    Views:
    522
  4. pstachy

    unique attribute value

    pstachy, Nov 5, 2006, in forum: XML
    Replies:
    2
    Views:
    564
    pstachy
    Nov 5, 2006
  5. ToshiBoy
    Replies:
    6
    Views:
    844
    ToshiBoy
    Aug 12, 2008
Loading...

Share This Page