Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Schema facets and Invalid values

Reply
Thread Tools

Schema facets and Invalid values

 
 
Nate
Guest
Posts: n/a
 
      11-21-2003
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, & -3276 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
 
Reply With Quote
 
 
 
 
Nate
Guest
Posts: n/a
 
      12-05-2003
Can anyone help me with this?

Thanks,
-Nate

(Nate) wrote in message news:<(E-Mail Removed). com>...
> 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, & -3276 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

 
Reply With Quote
 
 
 
 
Nate
Guest
Posts: n/a
 
      12-05-2003
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:<(E-Mail Removed). com>...
> 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, & -3276 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

 
Reply With Quote
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      12-05-2003
In article <(E-Mail Removed) >,
Nate <(E-Mail Removed)> 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, & -3276 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
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Nate
Guest
Posts: n/a
 
      12-10-2003
That worked perfectly! Thanks for the help.

-Nate
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
w3c Schema naming patterns and template-based schema generation Steve Jorgensen XML 0 08-09-2005 08:05 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM
Fixed precision floating point and locale facets Roger Leigh C++ 4 11-12-2003 08:56 PM



Advertisments