473,503 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restrict Data Range

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.

Dec 8 '05 #1
2 1211
<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
<bo*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr 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.

Dec 8 '05 #2
The clouds have lifted!

Thanks a million.

Dec 8 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2658
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
2
1332
by: atif | last post by:
I hav a prob with the textfield i want to restrict this field so that only integer values should b entered e.g 0-9 n no english or special characters should b entered in the text field Posted...
5
2212
by: ad | last post by:
I want to restrict only a range of ip can access my web application. How can I do that ?
4
2041
by: richard.mcgrath | last post by:
Hi, I have to restrict access to a site based on IP address. While I have been able to this successfully with code in the Global.aspx file, some if the IP address are not single IP addresses...
12
2470
by: Me | last post by:
I'm trying to wrap my head around the wording but from what I think the standard says: 1. it's impossible to swap a restrict pointer with another pointer, i.e. int a = 1, b = 2; int *...
7
5308
by: Chris Fulstow | last post by:
Hi, I need to restirict access at the page level to a range of IP addresses. What's the best approach? I thought of building an HTTP module that could compare the requesting IP with a...
5
1715
by: Haro Panosyan | last post by:
#include <iostream> #include <map> #include <string> using namespace std; void InitMap( map<string, int>& Map) { Map = 0;
6
2360
by: rainy6144 | last post by:
Does the following code have defined behavior? double *new_array(unsigned n) { double *p = malloc(n * sizeof(double)); unsigned i; for (i = 0; i < n; i++) p = 0.0; return p; }
3
3007
by: kmnotes04 | last post by:
Could anyone tell me how to restrict the date range for items that appear on a report? Old items from previous years appear on the report. I was asked to have only this year's items (and beyond)...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.