Possible with schema?

Discussion in 'XML' started by Lord0, Feb 23, 2007.

  1. Lord0

    Lord0 Guest

    Is it possible to validate/check for the following using a schema?

    <question answer="yes">
    <answer>This is the answer</answer>
    </question>

    OR

    <question answer="no" />

    Where "question" can change.....i.e.

    The schema fragment which *would* validate this:

    <question1 answer="yes">
    <answer>This is the answer</answer>
    </question1>

    OR

    <question1 answer="no" />

    Would also be able to validate this:

    <question2 answer="yes">
    <answer>This is the answer</answer>
    </question2>

    OR

    <question2 answer="no" />

    WITHOUT hardcoding "question1", "question2" etc in the schema

    Maybe Im going Friday afternoon mad!

    Cheers

    Lord0
    Lord0, Feb 23, 2007
    #1
    1. Advertising

  2. Redesign as <question number="2" ....>.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Feb 23, 2007
    #2
    1. Advertising

  3. Lord0

    Lord0 Guest

    On 23 Feb, 15:37, Joseph Kesselman <> wrote:
    > Redesign as <question number="2" ....>.
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Hmm, I got as far as.......

    <choice>
    <element name="question" type="this:noAttributeType" />
    <element name="question"
    type="this:yesAttributeWithDescriptionType" />
    </choice>

    <complexType name="noAttributeType">
    <attribute name="value" type="string" fixed="no" use="required"/>
    <attribute name="number" type="nonNegativeInteger" use="required"/
    >

    </complexType>

    <complexType name="yesAttributeWithDescriptionType">
    <sequence>
    <element name="description" type="string" />
    </sequence>
    <attribute name="value" type="string" fixed="no" use="required"/>
    <attribute name="number" type="nonNegativeInteger" use="required"/
    >

    </complexType>

    but of course I get "Unique Particle Attribution" violation.
    Lord0, Feb 23, 2007
    #3
  4. Lord0

    Lord0 Guest

    Sorry about formatting above ^^
    Lord0, Feb 23, 2007
    #4
  5. Lord0

    Guest

    On 23 Feb, 15:45, "Lord0" <> wrote:
    > On 23 Feb, 15:37, Joseph Kesselman <> wrote:
    >
    > > Redesign as <question number="2" ....>.

    >
    > > --
    > > Joe Kesselman / Beware the fury of a patient man. -- John Dryden

    >
    > Hmm, I got as far as.......
    >
    > <choice>
    > <element name="question" type="this:noAttributeType" />
    > <element name="question"
    > type="this:yesAttributeWithDescriptionType" />
    > </choice>
    >...


    I think what you're trying to do requires a co-constraint, and is not
    currently possible with XML schema. I believe Relax-NG can do this.

    You could aim for something like:

    <question number="2"><yes answer="This is the answer"></...

    or some variation on that theme.

    Pete.
    --
    =============================================
    Pete Cordell
    Tech-Know-Ware Ltd
    for XML to C++ data binding visit
    http://www.tech-know-ware.com/lmx
    (or http://www.xml2cpp.com)
    =============================================
    , Feb 23, 2007
    #5
    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,519
    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:
    551
    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:
    408
    Andy Dingley
    Sep 4, 2003
  4. Fred Smith
    Replies:
    1
    Views:
    938
    Martin Honnen
    Feb 5, 2004
  5. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,244
    Stanimir Stamenkov
    Apr 25, 2005
Loading...

Share This Page