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

Validation fails when mixing XSD and DTD

ben
When running the code below the validation fails when the first line of
my xml contains

<legalEnvelope version="1.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >

If I change this line to

<legalEnvelope version="1.1">

It validated fine.

Anyone have any idea why this is?

The exact error this throws is:
An unhandled exception of type 'System.Xml.Schema.XmlSchemaException'
occurred in system.xml.dll
Additional information: System error.

===========CODE==================
XmlValidatingReader myVReader = null;
System.Xml.XmlDocument xd = new XmlDocument();
string f = @"C:\dev\batchUpload\xslt\sample.xml";
string dtdFileName =
@"C:\dev\bwiseley_eFile\vobEFile\EFM\Common\classe s\LegalXml\Xml\CLLegalXml.dtd";

xd.LoadXml(LNSea.IO.FileHelper.FileToString(f));

string myRootNodeName = xd.DocumentElement.Name; //
this.DocumentElement.Name;
XmlDocument myNewDom = new XmlDocument();

myNewDom.AppendChild(
myNewDom.CreateDocumentType(myRootNodeName,null,dt dFileName,null));
myNewDom.AppendChild(myNewDom.ImportNode(xd.Docume ntElement,true));

myVReader = new XmlValidatingReader(new XmlTextReader(new
StringReader(myNewDom.InnerXml)));

myVReader.ValidationType = ValidationType.DTD;
while(myVReader.Read());

Nov 12 '05 #1
1 1659
Could you attached a validation event handler to the validating reader,
which catches the XmlSchemaException and also find out the message, line
number, line position which caused it?

Thanks.

"ben" <wi******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
When running the code below the validation fails when the first line of
my xml contains

<legalEnvelope version="1.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >

If I change this line to

<legalEnvelope version="1.1">

It validated fine.

Anyone have any idea why this is?

The exact error this throws is:
An unhandled exception of type 'System.Xml.Schema.XmlSchemaException'
occurred in system.xml.dll
Additional information: System error.

===========CODE==================
XmlValidatingReader myVReader = null;
System.Xml.XmlDocument xd = new XmlDocument();
string f = @"C:\dev\batchUpload\xslt\sample.xml";
string dtdFileName =
@"C:\dev\bwiseley_eFile\vobEFile\EFM\Common\classe s\LegalXml\Xml\CLLegalXml.
dtd";
xd.LoadXml(LNSea.IO.FileHelper.FileToString(f));

string myRootNodeName = xd.DocumentElement.Name; //
this.DocumentElement.Name;
XmlDocument myNewDom = new XmlDocument();

myNewDom.AppendChild(
myNewDom.CreateDocumentType(myRootNodeName,null,dt dFileName,null));
myNewDom.AppendChild(myNewDom.ImportNode(xd.Docume ntElement,true));

myVReader = new XmlValidatingReader(new XmlTextReader(new
StringReader(myNewDom.InnerXml)));

myVReader.ValidationType = ValidationType.DTD;
while(myVReader.Read());

Nov 12 '05 #2

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

Similar topics

16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
5
by: Dennis C. Drumm | last post by:
Is there a way to prevent the user from leaving a tab on a TabControl until all the controls on that tab have finished validating? The problem I am experiencing is when a control fails its...
0
by: Brian Conway | last post by:
I am having some validation and insertion problems. I am using a date picker that takes the selected date and puts it to ("dd-MMM-yyyy") format, as this was the only format that Oracle would...
3
by: Gary Varga | last post by:
In the file WebUIValidation.js, when a postback that doesn't fail the validation has a javascript error saying summary is undefined in the ValidationSummaryOnSubmit function....
9
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected......
2
by: Chad | last post by:
I have a textbox control, txtMeasurement, that I want to allow only numeric decimal input. I thought to use a client side validation control to ensure that the data entered is of type "Double". ...
1
by: Niclas | last post by:
Hi, How do I indicate what field fails a validation, usually you see a red star next to the faild field on a form. Is this built in functionality in the valdaition controls or shall I code this...
12
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug...
2
by: turboJeeper | last post by:
I have a form with 16 fields, 10 of which use the RequiredFieldValidator controls. I want to display a custom message when the validation fails. However, all the validators have ClientScript...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.