Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Restrict Data Range

Reply
Thread Tools

Restrict Data Range

 
 
bogus1one@yahoo.com
Guest
Posts: n/a
 
      12-08-2005
To all you XML experts, let's say I have the following in an XML doc:

<heading units="TRUE">55</heading>

I would like to develop a schema that will both provide for an
enumeration for the attribute and restrict the input to some range of
values. In the example above, I want the enumeration to be restricted
to TRUE and MAG. And, I want the valid values the text to be 0 through
359. I seem to be able to get one or the other but not both. This is
what I have currently:

<xs:element name="heading">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:attribute name="units" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TRUE"/>
<xs:enumeration value="MAG"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

It is my understanding that facets can only be applied to simple types
and that once you add an attribute to an element, it becomes a complex
type. So, how do you work around this?

Thanks for your help.

 
Reply With Quote
 
 
 
 
Stan Kitsis [MSFT]
Guest
Posts: n/a
 
      12-08-2005
<xs:simpleType name="tfType">

<xs:restriction base="xs:string">

<xs:enumeration value="TRUE"/>

<xs:enumeration value="MAG"/>

</xs:restriction>

</xs:simpleType>



<xs:simpleType name="myNumbers">

<xs:restriction base="xs:unsignedShort">

<xs:minInclusive value="0"/>

<xs:maxInclusive value="359"/>

</xs:restriction>

</xs:simpleType>



<xs:complexType name="headingType">

<xs:simpleContent>

<xs:extension base="myNumbers">

<xs:attribute name="units" type="tfType"/>

</xs:extension>

</xs:simpleContent>

</xs:complexType>



<xs:element name="heading" type="headingType"/>


--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> To all you XML experts, let's say I have the following in an XML doc:
>
> <heading units="TRUE">55</heading>
>
> I would like to develop a schema that will both provide for an
> enumeration for the attribute and restrict the input to some range of
> values. In the example above, I want the enumeration to be restricted
> to TRUE and MAG. And, I want the valid values the text to be 0 through
> 359. I seem to be able to get one or the other but not both. This is
> what I have currently:
>
> <xs:element name="heading">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="xs:unsignedShort">
> <xs:attribute name="units" use="required">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="TRUE"/>
> <xs:enumeration value="MAG"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> It is my understanding that facets can only be applied to simple types
> and that once you add an attribute to an element, it becomes a complex
> type. So, how do you work around this?
>
> Thanks for your help.
>



 
Reply With Quote
 
 
 
 
bogus1one@yahoo.com
Guest
Posts: n/a
 
      12-08-2005
The clouds have lifted!

Thanks a million.

 
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
How can I transform source range to destination range that is thesame as source? Lambda C++ 2 07-16-2008 05:18 PM
range() is not the best way to check range? Summercoolness@gmail.com Python 46 07-25-2006 08:10 PM
How to restrict IP range ad ASP .Net 1 08-21-2005 01:57 PM
Scene range vs dynamic range Robert Feinman Digital Photography 2 07-04-2005 09:30 PM
How can we restrict the ip range to access my web application ad ASP .Net 5 06-05-2005 12:48 PM



Advertisments