XSD: ways to deal with conditionals on attribute value?

Discussion in 'XML' started by Piper707@hotmail.com, Dec 30, 2005.

  1. Guest

    Hi,

    I need to generate an XML file for the result which differs based on
    the value of a "status" attribute.

    i.e for an error condition it would look something like this:

    <result status="failure">
    <errorBlock>
    </result>

    a success condition (an empty result block):

    <result status="success">
    </result>

    I understand that XSD does not support conditional processing based on
    the value of an attribute.

    One way would be to have a tag called "failure" or "success" itself in
    the body of the <result>, but then having an empty element seems
    wasteful. I would like to have an atribute to do the same thing.

    How does one deal with situations like these?

    Thanks fo any help
    Rohit.
     
    , Dec 30, 2005
    #1
    1. Advertisements

  2. Zafar Abbas Guest

    Re: ways to deal with conditionals on attribute value?

    You will have to write application code on top of XSD validation to process
    pass/fail values of the status attribute.
    You could also consider using Schematron in this situtation. XSD does not
    provide any help here.

    <> wrote in message
    news:...
    > Hi,
    >
    > I need to generate an XML file for the result which differs based on
    > the value of a "status" attribute.
    >
    > i.e for an error condition it would look something like this:
    >
    > <result status="failure">
    > <errorBlock>
    > </result>
    >
    > a success condition (an empty result block):
    >
    > <result status="success">
    > </result>
    >
    > I understand that XSD does not support conditional processing based on
    > the value of an attribute.
    >
    > One way would be to have a tag called "failure" or "success" itself in
    > the body of the <result>, but then having an empty element seems
    > wasteful. I would like to have an atribute to do the same thing.
    >
    > How does one deal with situations like these?
    >
    > Thanks fo any help
    > Rohit.
    >
     
    Zafar Abbas, Dec 30, 2005
    #2
    1. Advertisements

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. Matthet
    Replies:
    2
    Views:
    821
    Matthet
    Sep 24, 2003
  2. Stone
    Replies:
    0
    Views:
    444
    Stone
    Nov 24, 2004
  3. rbt

    deal or no deal

    rbt, Dec 22, 2005, in forum: Python
    Replies:
    7
    Views:
    848
    Duncan Smith
    Dec 28, 2005
  4. Replies:
    1
    Views:
    4,852
    Joe Kesselman
    Aug 2, 2006
  5. smoother
    Replies:
    0
    Views:
    532
    smoother
    Aug 2, 2006
  6. Replies:
    8
    Views:
    739
  7. Joshua Mostafa
    Replies:
    4
    Views:
    2,511
    Joshua Mostafa
    May 11, 2007
  8. Adam dR.
    Replies:
    0
    Views:
    614
    Adam dR.
    Nov 2, 2008
Loading...