Schema facets and Invalid values

N

Nate

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
 
N

Nate

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
 
P

Patrick TJ McPhee

[...]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top