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. Advertising

  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. 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. Charles Fineman
    Replies:
    2
    Views:
    320
    Charles Fineman
    Feb 25, 2004
  2. Replies:
    1
    Views:
    664
    Henry S. Thompson
    Dec 21, 2005
  3. rbt

    deal or no deal

    rbt, Dec 22, 2005, in forum: Python
    Replies:
    7
    Views:
    566
    Duncan Smith
    Dec 28, 2005
  4. Replies:
    1
    Views:
    4,335
    Joe Kesselman
    Aug 2, 2006
  5. Replies:
    8
    Views:
    530
Loading...

Share This Page