Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 10th, 2006, 11:45 PM
hufaunder@yahoo.com
Guest
 
Posts: n/a
Default Validate Values

I want to validate an xml document with an xsd reference document. I am
able to validate the tags but not the values. Here is an example:

I define the following type:

<xsd:simpleType name="Sample">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Double" />
<xsd:enumeration value="Integer" />
</xsd:restriction>
</xsd:simpleType>

That type I use later like this:

<xsd:element name="Type" type="Sample" minOccurs="1" maxOccurs="1" />

Validating <BadTag>Double</Typefails because of the opening tag.
Validating <Type>BadValue</Typesucceeds.

With the restriction for the type "Sample" should this not give an
error? How do I validate the actual values?

Here is the code I am using for validation:

XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("Sample.xsd", xsdFile);
settings.ValidationEventHandler += new
ValidationEventHandler(OnValidationError);
settings.ValidationType = ValidationType.Schema;
XmlDocument doc = new XmlDocument();
doc.Load(XmlReader.Create(xmlFile, settings));

Thanks

 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles