473,486 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Restricting data

Hi

I am trying to put value restrictions on certain elements in an xml file
using a schema file.
The syntax in my schema file looks like the following
<xs:element name="AXYZMachines" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="MotionParameters">
<xs:complexType>
<xs:sequence>
<xs:element name="FeedRateMAX" type="xs:double">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:element>
<xs:element name="PlungeRateMAX" type="xs:string"
minOccurs="0" />
<xs:element name="TravelRateMAX" type="xs:string"
minOccurs="0" />
<xs:element name="TravelRate" type="xs:string" minOccurs="0" />
<xs:element name="PlungeRate" type="xs:string" minOccurs="0" />
<xs:element name="FeedRate" type="xs:string" minOccurs="0" />
<xs:element name="JogSpeedMode" type="xs:string" minOccurs="0"
/>
<xs:element name="SeekXYSpeed" type="xs:string" minOccurs="0" />
<xs:element name="SeekZSpeed" type="xs:string" minOccurs="0" />
<xs:element name="JerkGrate" type="xs:string" minOccurs="0" />
<xs:element name="AccelerationG" type="xs:string"
minOccurs="0" />
<xs:element name="AccelMAX" type="xs:string" minOccurs="0" />
<xs:element name="JerkMAX" type="xs:string" minOccurs="0" />
<xs:element name="CentripetalG" type="xs:string" minOccurs="0"
/>
<xs:element name="BrakeG" type="xs:string" minOccurs="0" />
<xs:element name="ArcError" type="xs:string" minOccurs="0" />
<xs:element name="MinLength" type="xs:string" minOccurs="0" />
<xs:element name="CornerPause" type="xs:string" minOccurs="0" />
<xs:element name="StartPause" type="xs:string" minOccurs="0" />
<xs:element name="JerkFactor" type="xs:string" minOccurs="0" />
<xs:element name="CentripetalAcceleration" type="xs:string"
minOccurs="0" />
<xs:element name="LinearAcceleration" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>

I also have the following C# code that reads the schema in

dsMachineParameters = new DataSet("MachineParameters");
dsMachineParameters.ReadXmlSchema("SchemaA.xsd");

I get the following exception from my C# code:

The 'http/://www.w3.org/2001/XMLSchema:restriction' element is not supported
in this context. How can I add restrictions ranges on values?
--
Don
Jun 27 '08 #1
5 2437
Don wrote:
<xs:element name="FeedRateMAX" type="xs:double">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:element>
I think you need
<xs:element name="FeedRateMAX">
<xs:simpleType>
<xs:restriction base="xs:double">
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
I tried the following:
<xs:element name="FeedRateMAX" type="xs:double">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

and get the following exceptiion:
The type attribute cannot be present with either simpleType or complexType
--
Don
"Martin Honnen" wrote:
Don wrote:
<xs:element name="FeedRateMAX" type="xs:double">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:element>

I think you need
<xs:element name="FeedRateMAX">
<xs:simpleType>
<xs:restriction base="xs:double">
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #3
Don wrote:
I tried the following:
<xs:element name="FeedRateMAX" type="xs:double">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

and get the following exceptiion:
The type attribute cannot be present with either simpleType or complexType
Well that is not what I suggested, drop the type="xs:double" from the
xs:element.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #4
Hi Martin,

Thanks for your input. The exception does not happen anymore but now when I
load the a datagrid using the following

dsMachineParameters = new DataSet("MachineParameters");
mydatagrid = new DataGrid();
mydatagrid.DataSource = dsMachineParameters;
dataGridView1.Controls.Add(mydatagrid);

I am still allowed to change the value to something greater than 1000. This
is not what I expected?

--
Don
"Martin Honnen" wrote:
Don wrote:
I tried the following:
<xs:element name="FeedRateMAX" type="xs:double">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1000"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

and get the following exceptiion:
The type attribute cannot be present with either simpleType or complexType

Well that is not what I suggested, drop the type="xs:double" from the
xs:element.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #5
Don wrote:
Thanks for your input. The exception does not happen anymore but now when I
load the a datagrid using the following

dsMachineParameters = new DataSet("MachineParameters");
mydatagrid = new DataGrid();
mydatagrid.DataSource = dsMachineParameters;
dataGridView1.Controls.Add(mydatagrid);

I am still allowed to change the value to something greater than 1000. This
is not what I expected?
I think in terms of the W3C XML schema language you have the right type
definition now. I don't know however whether such restrictions in a
schema are enforced by DataSets or DataGridViews. I did a quick test
here and it indeed looks as if the DataSet does not enforce such
restrictions like minInclusive or maxInclusive. I am not sure how to
change that. You might want to ask in an ADO.NET group.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #6

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

Similar topics

2
2692
by: Xenophobe | last post by:
I have a popup window (required by the client) containing a form and would like to prevent users from accessing it directly. They are instead required to access the page via a hyperlink on another...
5
2319
by: MX1 | last post by:
Here's an interesting one. I have a database that has user level security invoked. The design is normalized and I have one field in particular called Rep ID. Any thoughts on how I can allow all...
5
1343
by: ronchito | last post by:
Hi, I have a database that contains only one table. This table contains highly confidential/unique information that, if viewed or copied as a whole, would give away much of my company's...
4
4608
by: Dennis C. Drumm | last post by:
Is there a way with C# to allow one class access to a method or field of another class, without making that method or field visible to all other classes, as would be the case when making the method...
3
4650
by: volume | last post by:
Restricting a windows textbox (edit item) to digits only. Is there a windows option, using .NET C#, to only allow a user to enter digits ONLY? If so, what is the flag or setting? If no, what is...
6
3690
by: Altramagnus | last post by:
I have searched throught the newsgroups on how to restrict entry in textboxes, for example, I only want the textbox to only accept numberic. The standard answer is to use the KeyPress event....
0
1000
by: CLEAR-RCIC | last post by:
Hi. I'm using web controls in my web application. Using IIS, I am trying to restrict an IP address from viewing one of my contols. When I restrict the IP Address using the Directory Security tab...
1
2154
by: Piper707 | last post by:
Hi, I'd like to know if there are any more ways of restricting an XML document to having only non-empty tags (containing Strings). I can think of 2 ways: 1) <xs:simpleType name="tagName">
2
2614
by: Brett Romero | last post by:
I have a CustomDataGrid that inherits DataGrid. I use the filter below via a context menu, which works fine. ( ( DataTable ) this.DataSource ).DefaultView.RowFilter = filterexpress; The...
8
8689
by: sneddo | last post by:
Ok I am trying to do the above, I have got a script that will restrict the length but it requires the user to enter the field and hit a key, before it will work. This would normaly be find, but...
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
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,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
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
7330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4865
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
3070
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...
1
598
muto222
php
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.