Schema facets and Invalid values

Discussion in 'XML' started by Nate, Nov 21, 2003.

  1. Nate

    Nate Guest

    Hello,

    I'd like to somehow put minIncl and maxIncl around the data I am
    sending from my producer. One of the requirements is to allow the
    producer to send an invalid number to the consumer. The consumer will
    know what the invalid value is based on an INV attribute being set.

    Here's a partial schema of what I'm talking about:
    <xs:element name="data" minOccurs="0">
    <xs:complexType>
    <xs:attribute name="V">
    <xs:simpleType>
    <xs:restriction base="xs:short">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="300"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="U" type="UnitsAttributeType" fixed="/min"/>
    <xs:attribute name="INV" type="xs:short" fixed="-32768"/>
    </xs:complexType>
    </xs:element>

    XML the producer would send
    <data V="50" U="ms" INV="-32768" />
    <data V="60" />
    <data V="-32768" />
    <data V="-32768" />
    <data V="25" />
    <data V="100" />

    The consumer reads in the data and displays it. If they get an
    invalid they display an invalid message.

    The problem, which can you obviously see by now, is that when the
    invalid number is sent the parser throws an error that the value (V)
    is outside the range (0-300). So is there a way to do what I'm trying
    to do? (i.e. range=0-300, & -32768) or is this a dream and the only
    way is to make the INV a Boolean and send it every time?

    Thanks for the help,
    -Nate
     
    Nate, Nov 21, 2003
    #1
    1. Advertising

  2. Nate

    Nate Guest

    Can anyone help me with this? :)

    Thanks,
    -Nate

    (Nate) wrote in message news:<>...
    > Hello,
    >
    > I'd like to somehow put minIncl and maxIncl around the data I am
    > sending from my producer. One of the requirements is to allow the
    > producer to send an invalid number to the consumer. The consumer will
    > know what the invalid value is based on an INV attribute being set.
    >
    > Here's a partial schema of what I'm talking about:
    > <xs:element name="data" minOccurs="0">
    > <xs:complexType>
    > <xs:attribute name="V">
    > <xs:simpleType>
    > <xs:restriction base="xs:short">
    > <xs:minInclusive value="0"/>
    > <xs:maxInclusive value="300"/>
    > </xs:restriction>
    > </xs:simpleType>
    > </xs:attribute>
    > <xs:attribute name="U" type="UnitsAttributeType" fixed="/min"/>
    > <xs:attribute name="INV" type="xs:short" fixed="-32768"/>
    > </xs:complexType>
    > </xs:element>
    >
    > XML the producer would send
    > <data V="50" U="ms" INV="-32768" />
    > <data V="60" />
    > <data V="-32768" />
    > <data V="-32768" />
    > <data V="25" />
    > <data V="100" />
    >
    > The consumer reads in the data and displays it. If they get an
    > invalid they display an invalid message.
    >
    > The problem, which can you obviously see by now, is that when the
    > invalid number is sent the parser throws an error that the value (V)
    > is outside the range (0-300). So is there a way to do what I'm trying
    > to do? (i.e. range=0-300, & -32768) or is this a dream and the only
    > way is to make the INV a Boolean and send it every time?
    >
    > Thanks for the help,
    > -Nate
     
    Nate, Dec 5, 2003
    #2
    1. Advertising

  3. Nate

    Nate Guest

    Hello,

    Let me add one more thing to make sure I am making myself clear.
    Here's what I am trying to do.

    valid values are: 1700 thur 4800 and -32768
    1700 = okay
    2500 = okay
    100 = ERROR
    -32768 = okay
    - 1000 = ERROR

    Can I put something in the schema to check this correctly?

    Thanks for the help,
    -Nate

    (Nate) wrote in message news:<>...
    > Hello,
    >
    > I'd like to somehow put minIncl and maxIncl around the data I am
    > sending from my producer. One of the requirements is to allow the
    > producer to send an invalid number to the consumer. The consumer will
    > know what the invalid value is based on an INV attribute being set.
    >
    > Here's a partial schema of what I'm talking about:
    > <xs:element name="data" minOccurs="0">
    > <xs:complexType>
    > <xs:attribute name="V">
    > <xs:simpleType>
    > <xs:restriction base="xs:short">
    > <xs:minInclusive value="0"/>
    > <xs:maxInclusive value="300"/>
    > </xs:restriction>
    > </xs:simpleType>
    > </xs:attribute>
    > <xs:attribute name="U" type="UnitsAttributeType" fixed="/min"/>
    > <xs:attribute name="INV" type="xs:short" fixed="-32768"/>
    > </xs:complexType>
    > </xs:element>
    >
    > XML the producer would send
    > <data V="50" U="ms" INV="-32768" />
    > <data V="60" />
    > <data V="-32768" />
    > <data V="-32768" />
    > <data V="25" />
    > <data V="100" />
    >
    > The consumer reads in the data and displays it. If they get an
    > invalid they display an invalid message.
    >
    > The problem, which can you obviously see by now, is that when the
    > invalid number is sent the parser throws an error that the value (V)
    > is outside the range (0-300). So is there a way to do what I'm trying
    > to do? (i.e. range=0-300, & -32768) or is this a dream and the only
    > way is to make the INV a Boolean and send it every time?
    >
    > Thanks for the help,
    > -Nate
     
    Nate, Dec 5, 2003
    #3
  4. In article <>,
    Nate <> wrote:

    [...]

    % is outside the range (0-300). So is there a way to do what I'm trying
    % to do? (i.e. range=0-300, & -32768) or is this a dream and the only
    % way is to make the INV a Boolean and send it every time?

    You can define the type as a union of a type which accepts 0--300 and
    a type which accepts -32768 only. Something like

    <xs:simpleType><xs:union>
    <xs:simpleType>
    <xs:restriction base='xs:short'>
    <xs:minInclusive value='0'/>
    <xs:maxInclusive value='300'/>
    </xs:restriction>
    </xs:simpleType>
    <xs:simpleType>
    <xs:restriction base='xs:short'>
    <xs:minInclusive value='-32768'/>
    <xs:maxInclusive value='-32768'/>
    </xs:restriction>
    </xs:simpleType>
    </xs:union></xs:simpleType>

    I'm not sure if there's a better way to expression the -32768, however
    you could define it to be a string `invalid' if you wanted to.

    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Dec 5, 2003
    #4
  5. Nate

    Nate Guest

    That worked perfectly! Thanks for the help.

    -Nate
     
    Nate, Dec 10, 2003
    #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,614
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,296
    Stanimir Stamenkov
    Apr 25, 2005
  3. David List
    Replies:
    0
    Views:
    307
    David List
    Aug 6, 2003
  4. Roger Leigh
    Replies:
    4
    Views:
    472
    Roger Leigh
    Nov 12, 2003
  5. Replies:
    0
    Views:
    404
Loading...

Share This Page