473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ADO.NET schema validation bug?

Hello,

Am I doing something wrong or is it a bug?
What I’m trying to do is this:
I create a dataset. Load a schema, read my XML and bind the dataset to a datagridview.

Not too complicated, but the thing is that the XML is not validated the way I want it to be validated.

What I want is an XML file with exactly 18 digits. The schema looks like this:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns="" finalDefault="" id="BLA" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3.   <xs:element msdata:IsDataSet="true" msdata:Locale="en-US" name="BLA">
  4.     <xs:complexType>
  5.       <xs:choice minOccurs="1" maxOccurs="unbounded">
  6.         <xs:element name="MEASUREMENT">
  7.           <xs:complexType>
  8.             <xs:sequence minOccurs="1" maxOccurs="1">
  9.               <xs:element minOccurs="1" maxOccurs="1" block="restriction" name="EANCODE">
  10.                 <xs:simpleType>
  11.                   <xs:restriction base="xs:string">
  12.                     <xs:pattern value="([0-9])*" />
  13.                     <xs:minLength value="18" />
  14.                     <xs:maxLength value="18" />
  15.                     <xs:whiteSpace value="collapse" />
  16.                   </xs:restriction>
  17.                 </xs:simpleType>
  18.               </xs:element>
  19.             </xs:sequence>
  20.           </xs:complexType>
  21.         </xs:element>
  22.       </xs:choice>
  23.     </xs:complexType>
  24.   </xs:element>
  25. </xs:schema>
  26.  
The XML file looks like this. I adapted the XML data a little to force a validation error, but it doesn’t seem like it is validating at all except when I put in a 19 digit string.
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" standalone="yes"?>
  2. <BLA>
  3.   <MEASUREMENT>
  4.     <EANCODE>123456789012345678</EANCODE>
  5.   </MEASUREMENT>
  6.   <MEASUREMENT>
  7.     <EANCODE>12345678901234567</EANCODE>
  8.   </MEASUREMENT>
  9.   <MEASUREMENT>
  10.     <EANCODE>12345678901234567A</EANCODE>
  11.   </MEASUREMENT>
  12.   <MEASUREMENT>
  13.     <EANCODE>123456789012345678</EANCODE>
  14.   </MEASUREMENT>
  15. </BLA>
  16.  

The code for loading the schema and the XML is pretty basic:
Expand|Select|Wrap|Line Numbers
  1. xmlDS = new DataSet();
  2.  
  3. xmlDS.ReadXmlSchema(@”EAN.XSD”);
  4. xmlDS.ReadXml(@”EAN.XML”);
  5.  
  6. this.dataGridView1.DataSource = xmlDS.Tables["MEASUREMENT"];
  7.  
Does anyone have a clue?
Nov 1 '07 #1
0 756

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Shone | last post by:
I would like to perform a 2-pass XML reading from a stream. Once using the Validating reader, just to confirm the validity against the schema, and next time to do a reading to extract the data....
1
by: Dan Bass | last post by:
There's an XML message I have, that has no namespace information. Then there is a XSD schema that is must validate against, but this has a targetNamespace and xmlns of...
1
by: Dan Bass | last post by:
There's an XML message I have, that has no namespace information. Then there is a XSD schema that is must validate against, but this has a targetNamespace and xmlns of...
1
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i...
0
by: Mark Parter | last post by:
I'm trying convert an XML Schema (http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net class using the XSD tool provided with the .NET 2 SDK. However, it's failing to generate...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...

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.