473,396 Members | 1,877 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,396 software developers and data experts.

Validation of xml document at load time.



I am using xml serialization to generate my xml document. I am getting
the data as stream of memory and then converting it to xml document
object without saving it to the file system.

How do I validate this memory stream of data at load time with xml
schema ?

I may have to validate with multiple schemas at a later time.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
3 2657
Hi Emily

You need a layered approach here. Use the XmlTextReader on your stream, then
construct a ValidatingXmlReader using the TextReader, and then pass the
validating reader through to the Load method of your XmlDocument.

Code like this:

Dim t As New Xml.XmlTextReader(stream)
Dim v As New Xml.XmlValidatingReader(t)
Dim doc As New Xml.XmlDocument
doc.Load(v)

HTH

Nigel

"Emily John" wrote:


I am using xml serialization to generate my xml document. I am getting
the data as stream of memory and then converting it to xml document
object without saving it to the file system.

How do I validate this memory stream of data at load time with xml
schema ?

I may have to validate with multiple schemas at a later time.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2


Exactly ! I did the same thing. But where does I make a call to validate
it against schema ?

Does XMLValidatingReader does the validation automatically ? Which
schema it validates against ?? I need to clearly understannd the
doc.Load(v) call adn how is validates.

Can you please help ??

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Hi Emily

Take a look at the ValidationType and Schemas properties.

With ValidationType set to Auto, then if you can use the xsi:schemaLocation
/ xsi:noNamespaceSchemaLocation to hook into validation.

You can also add a Schema or collection of Schemas to validate against with
the Schemas property.

HTH

Nigel Armstrong

"Emily John" wrote:


Exactly ! I did the same thing. But where does I make a call to validate
it against schema ?

Does XMLValidatingReader does the validation automatically ? Which
schema it validates against ?? I need to clearly understannd the
doc.Load(v) call adn how is validates.

Can you please help ??

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4

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

Similar topics

6
by: Hernán Castelo | last post by:
should i to validate all the "Request"s calls like Request.FORM("...") and Request.Cookies("...") ???? if it is so, i have to see inside every "Input" elements like "Text" and even "Hidden"...
6
by: Kenneth | last post by:
Hello, I'm having some serious problems debugging a script that I'm trying to make work. I'm working on a form where a user can type in a time (in the format of HH:MM), and another script...
41
by: Gérard Talbot | last post by:
Cross-posted to: comp.infosystems.www.authoring.html and alt.html Followup-to: comp.infosystems.www.authoring.html 1- One day, I stumbled across a website that offers to validate webpages. What...
4
by: Wayne Wengert | last post by:
I have an XML document and a corresponding xsd document I built. I want to validate the xml document against that Schema but when I use the MSDN validator it has no place to select the xsd...
3
by: Kent Ogletree | last post by:
I am porting a Java XML Validation class over to C# and I am having a problem finding exactly what I need to acomplish the task. First I need to test for well formedness. I know this is usually...
7
by: A.M | last post by:
Hi, I have a validation control in my page that upon any invalid data, it disables all buttons in the page. basicly i don't have any postback in the page if the validator finds any error. How...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
5
by: Damian Burrin | last post by:
Hi guy's i'm v new to this and probably getting this wrapped right round my head, but why can't i use something like wc3 to validate this. -----------------XML--------------------------- <?xml...
3
by: Adhal | last post by:
Hello, I have an XML and XSD file. When I do validation in the XML file I only get the first error. Is it possible to list all errors? One other question. -------------Microsoft Sample Code...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
0
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,...

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.