473,225 Members | 1,277 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,225 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 1805
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.