usage of "Choice" Compositor with Attributes/attribute

Discussion in 'XML' started by kosaraju.puneeth@gmail.com, Oct 26, 2005.

  1. Guest

    I want an element that must have either attribute A or B.


    <Thing1 A="aaa"/> <Thing1 B="bbb"/>


    I want to enforce this in my schema . If A and B were
    elements, I could use choice.


    <xs:attribute name="A"/>
    <xs:attribute name="B"/>


    <xs:element name="Thing1">
    <xs:complexType>
    <xs:choice >
    <xs:element ref="A"/>
    <xs:element ref="B"/>
    </xs:choice>
    </xs:complexType>
    </xs:element>


    But choice only works for elements, and I am stuck.
    Is there a way to do "choice" for attributes?
    And if so, how about for attributeGroups too?


    Making both attributes optional would accept valid input
    but not reject all invalid input. I am hoping for better.


    Thanks!
    , Oct 26, 2005
    #1
    1. Advertising

  2. No, XSD does not support this.

    --
    Stan Kitsis
    Program Manager, XML Technologies
    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm
    <> wrote in message
    news:...
    >I want an element that must have either attribute A or B.
    >
    >
    > <Thing1 A="aaa"/> <Thing1 B="bbb"/>
    >
    >
    > I want to enforce this in my schema . If A and B were
    > elements, I could use choice.
    >
    >
    > <xs:attribute name="A"/>
    > <xs:attribute name="B"/>
    >
    >
    > <xs:element name="Thing1">
    > <xs:complexType>
    > <xs:choice >
    > <xs:element ref="A"/>
    > <xs:element ref="B"/>
    > </xs:choice>
    > </xs:complexType>
    > </xs:element>
    >
    >
    > But choice only works for elements, and I am stuck.
    > Is there a way to do "choice" for attributes?
    > And if so, how about for attributeGroups too?
    >
    >
    > Making both attributes optional would accept valid input
    > but not reject all invalid input. I am hoping for better.
    >
    >
    > Thanks!
    >
    Stan Kitsis [MSFT], Oct 26, 2005
    #2
    1. Advertising

  3. Peter Flynn Guest

    Stan Kitsis [MSFT] wrote:

    > No, XSD does not support this.


    SGML does :)
    Well, sorta.

    ///Peter
    Peter Flynn, Oct 27, 2005
    #3
  4. Guest

    Thnx guys for your response :)
    , Oct 28, 2005
    #4
    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. Mickey Segal
    Replies:
    0
    Views:
    855
    Mickey Segal
    Feb 2, 2004
  2. Multicoder4002
    Replies:
    1
    Views:
    701
    Andrew Thompson
    Feb 13, 2004
  3. news
    Replies:
    0
    Views:
    362
  4. Mavis
    Replies:
    0
    Views:
    428
    Mavis
    Jun 1, 2006
  5. miles.jg
    Replies:
    16
    Views:
    854
    Alf P. Steinbach
    Nov 14, 2007
Loading...

Share This Page