Re: XML Schema question: attribute xor content

Discussion in 'XML' started by Martin Honnen, Aug 13, 2009.

  1. Jun wrote:

    > I have a simple (I hope) question about XML Schema. The problem is
    > that I want to declare an element that has either an attribute or some
    > content, but not both, e.g.:
    >
    > <myelement value="stuff"/>
    >
    > xor,
    >
    > <myelement>stuff</myelement>
    >
    > Is there a way to this with XML Schema?


    I don't see a way to specify that with the W3C XML schema language but
    Relax NG can do that:

    <element name="root" xmlns="http://relaxng.org/ns/structure/1.0">
    <zeroOrMore>
    <element name="myelement">
    <choice>
    <text/>
    <attribute name="value">
    <text/>
    </attribute>
    </choice>
    </element>
    </zeroOrMore>
    </element>


    --

    Martin Honnen
    http://msmvps.com/blogs/martin_honnen/
     
    Martin Honnen, Aug 13, 2009
    #1
    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. Markus
    Replies:
    1
    Views:
    1,580
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,277
    Stanimir Stamenkov
    Apr 25, 2005
  3. Gazza
    Replies:
    1
    Views:
    1,136
    Henry S. Thompson
    Dec 5, 2005
  4. Replies:
    3
    Views:
    2,897
  5. Verticon::

    Xml Schema OR, XOR

    Verticon::, May 10, 2007, in forum: XML
    Replies:
    5
    Views:
    595
    Joe Kesselman
    May 13, 2007
Loading...

Share This Page