473,405 Members | 2,262 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,405 software developers and data experts.

validating against schema with namespaces

I have a very complex XDR schema that uses namespaces:

xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:b="urn:schemas-microsoft-com:BizTalkServer"
xmlns:d="urn:schemas-microsoft-com:datatypes"

Do I need to build a custom validator in order to validate XML documents
against this schema? How does the XML parser know how to validate against
the extra namespaces?

For example, schemas-microsoft-com:datatypes allows for attributes such as
maxLength, minLength, etc. If my XML document contains a value that doesn't
meet these criteria, then the document should not be valid. Microsoft's
parser automagically validates correctly, using these custom attributes.

The "schemas-microsoft-com:BizTalkServer" is even more custom, allowing for
such things as a "FieldInfo" element with "format" attributes that specifiy
the exact format for dates and times. I'm pretty sure XmlValidatingReader
doesn't check for these special validations.
If I do have to build my own validator, does anyone have some samples I can
look at? Is there an easy way to do this?

Thanks, Ryan

Nov 12 '05 #1
1 1811
The XmlValidatingReader can validate xml files against XDR schemas. You
should add your XDR schemas to the Schemas property of XmlValidatingReader.
"urn:schemas-microsoft-com:xml-data" and
"urn:schemas-microsoft-com:datatypes" will be understood implicitly but you
need to provide the XDR schema for "urn:schemas-microsoft-com:BizTalkServer"
namespace since it is a custom namespace that the XDR schema parser cannot
understand.

Sample code:
XmlTextReader tr = new XmlTextReader(url);
XmlValidatingReader vr = new XmlValidatingReader(tr);
vr.ValidationType = ValidationType.XDR;
vr.Schemas.Add("urn:schemas-microsoft-com:BizTalkServer",
"BiztalkXDRSchema.xdr");
vr.Schemas.Add("myNS","myXdrSchema.xdr");
vr.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);

//Validate
while(vr.Read()) {
}

"Ryan" <no****@nospam.net> wrote in message
news:eZ****************@TK2MSFTNGP09.phx.gbl...
I have a very complex XDR schema that uses namespaces:

xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:b="urn:schemas-microsoft-com:BizTalkServer"
xmlns:d="urn:schemas-microsoft-com:datatypes"

Do I need to build a custom validator in order to validate XML documents
against this schema? How does the XML parser know how to validate against
the extra namespaces?

For example, schemas-microsoft-com:datatypes allows for attributes such as
maxLength, minLength, etc. If my XML document contains a value that doesn't meet these criteria, then the document should not be valid. Microsoft's
parser automagically validates correctly, using these custom attributes.

The "schemas-microsoft-com:BizTalkServer" is even more custom, allowing for such things as a "FieldInfo" element with "format" attributes that specifiy the exact format for dates and times. I'm pretty sure XmlValidatingReader
doesn't check for these special validations.
If I do have to build my own validator, does anyone have some samples I can look at? Is there an easy way to do this?

Thanks, Ryan

Nov 12 '05 #2

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

Similar topics

2
by: Will | last post by:
I have been having problems validating an XForms document against the XForms schema located at http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd. I have reduced the XForm to its bare bones...
6
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting...
1
by: Christian | last post by:
Hi, I load an Xml-file "customers.xml" into a DataSet (works fine) but then how do I validate it against a schema (e.g. customers.xsd) ? my customers.xml: <?xml version="1.0"...
3
by: Shailendra Batham | last post by:
hi guys I need your suggestions / opinion for doing this the right way. I have a XML and a Schema for the same What I want is when its validated against the schema, it should give custom...
1
by: Craig Beuker | last post by:
Hello, I am experimenting with this XmlValidatingReader and have a question about how it is working (or not working as would be the case) The sample documents and code are included at the end...
2
by: Ian | last post by:
I've inherited some xml that doesn't have a namespace and doesn't have a reference to the schema. The schema doesn't have a targetNamespace attribute. I'm trying to build a test tool, in C#, which...
0
by: wolf_y | last post by:
I'm a newbie to XML and primarily program in SAS, so even though I've consulted documentation, I can't translate into language I understand. I hope I can explain the problem clearly. The project...
1
Bob Ross
by: Bob Ross | last post by:
I am simply playing around with xml schemas to understand them better and came across this article - http://msdn2.microsoft.com/en-us/library/as3tta56.aspx The trouble is in this example no...
7
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I wrote a method to validate and xml file against a schema. If the file does not conform to the schema, it throws an error. It works fine except for one curious thing. If I try to validate an...
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: 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
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
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
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
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...

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.