In Schema, how to say "If one element exist, another element must exist"?

Discussion in 'XML' started by Y.S., Sep 16, 2003.

  1. Y.S.

    Y.S. Guest

    Hello All,

    I have the following schema:
    ....
    <xs:element name="data_type_id" type="xs:unsignedShort" />
    <xs:element name="data_value" type="xs:anyType" />
    ....

    What I want to do is to specify that "If 'data_value' element exists,
    'data_type_id' element MUST exist".

    How do I do that?

    Thanks very much
    Y.S., Sep 16, 2003
    #1
    1. Advertising

  2. Re: In Schema, how to say "If one element exist, another elementmust exist"?

    Y.S. schrieb:
    > Hello All,
    >
    > I have the following schema:
    > ...
    > <xs:element name="data_type_id" type="xs:unsignedShort" />
    > <xs:element name="data_value" type="xs:anyType" />
    > ...
    >
    > What I want to do is to specify that "If 'data_value' element exists,
    > 'data_type_id' element MUST exist".
    >
    > How do I do that?
    >
    > Thanks very much


    Hi,

    you should consider to embed data-value inside data_type_id either by
    attribute
    <data_type_id value="somewhat"/>
    or by element
    <data_type_id>
    <data_value/>
    </data_type_id>

    That's wy xml is structured. I cannot imagine that these kind of checks
    are possible with xml schemas but of cause I maybe wrong....

    Hope I could help you

    Thomas Scheffler
    Thomas Scheffler, Sep 17, 2003
    #2
    1. Advertising

  3. Y.S.

    Puff Addison Guest

    Re: In Schema, how to say "If one element exist, another elementmust exist"?

    Y.S. wrote:

    >Hello All,
    >
    >I have the following schema:
    >...
    ><xs:element name="data_type_id" type="xs:unsignedShort" />
    ><xs:element name="data_value" type="xs:anyType" />
    >...
    >
    >What I want to do is to specify that "If 'data_value' element exists,
    >'data_type_id' element MUST exist".
    >
    >How do I do that?
    >
    >Thanks very much
    >
    >

    Use <sequence>
    <xs:sequence minoccurs="0">
    <xs:element name="data_type_id" type="xs:unsignedShort" />
    <xs:element name="data_value" type="xs:anyType" />
    </xs:sequence>

    --
    J. D. Addison
    email
    Puff Addison, Sep 17, 2003
    #3
  4. Y.S.

    strajan Guest

    Include both the elements within a sequence like the following:
    =========
    <xs:sequence minOccurs="0" maxOccurs="1">
    <xs:element name="data_type_id" type="xs:unsignedShort" />
    <xs:element name="data_value" type="xs:anyType" />
    </xs:sequence>
    ==========

    Regards.
    "Y.S." <> wrote in message
    news:...
    > Hello All,
    >
    > I have the following schema:
    > ...
    > <xs:element name="data_type_id" type="xs:unsignedShort" />
    > <xs:element name="data_value" type="xs:anyType" />
    > ...
    >
    > What I want to do is to specify that "If 'data_value' element exists,
    > 'data_type_id' element MUST exist".
    >
    > How do I do that?
    >
    > Thanks very much
    strajan, Sep 17, 2003
    #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. Markus
    Replies:
    1
    Views:
    1,528
    Markus
    Nov 23, 2005
  2. Klaus Johannes Rusch

    Re: Convert DB2 schema to XML Schema

    Klaus Johannes Rusch, Aug 6, 2003, in forum: XML
    Replies:
    0
    Views:
    552
    Klaus Johannes Rusch
    Aug 6, 2003
  3. Brett Selleck

    Schema Metadata not a Metadata Schema

    Brett Selleck, Sep 4, 2003, in forum: XML
    Replies:
    1
    Views:
    412
    Andy Dingley
    Sep 4, 2003
  4. Fred Smith
    Replies:
    1
    Views:
    942
    Martin Honnen
    Feb 5, 2004
  5. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,251
    Stanimir Stamenkov
    Apr 25, 2005
Loading...

Share This Page