473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation fails when mixing XSD and DTD

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

<legalEnvelop e 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

<legalEnvelop e 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.Sch ema.XmlSchemaEx ception'
occurred in system.xml.dll
Additional information: System error.

===========CODE =============== ===
XmlValidatingRe ader myVReader = null;
System.Xml.XmlD ocument xd = new XmlDocument();
string f = @"C:\dev\batchU pload\xslt\samp le.xml";
string dtdFileName =
@"C:\dev\bwisel ey_eFile\vobEFi le\EFM\Common\c lasses\LegalXml \Xml\CLLegalXml .dtd";

xd.LoadXml(LNSe a.IO.FileHelper .FileToString(f ));

string myRootNodeName = xd.DocumentElem ent.Name; //
this.DocumentEl ement.Name;
XmlDocument myNewDom = new XmlDocument();

myNewDom.Append Child(
myNewDom.Create DocumentType(my RootNodeName,nu ll,dtdFileName, null));
myNewDom.Append Child(myNewDom. ImportNode(xd.D ocumentElement, true));

myVReader = new XmlValidatingRe ader(new XmlTextReader(n ew
StringReader(my NewDom.InnerXml )));

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

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

Thanks.

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

<legalEnvelop e 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

<legalEnvelop e 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.Sch ema.XmlSchemaEx ception'
occurred in system.xml.dll
Additional information: System error.

===========CODE =============== ===
XmlValidatingRe ader myVReader = null;
System.Xml.XmlD ocument xd = new XmlDocument();
string f = @"C:\dev\batchU pload\xslt\samp le.xml";
string dtdFileName =
@"C:\dev\bwisel ey_eFile\vobEFi le\EFM\Common\c lasses\LegalXml \Xml\CLLegalXml .
dtd";
xd.LoadXml(LNSe a.IO.FileHelper .FileToString(f ));

string myRootNodeName = xd.DocumentElem ent.Name; //
this.DocumentEl ement.Name;
XmlDocument myNewDom = new XmlDocument();

myNewDom.Append Child(
myNewDom.Create DocumentType(my RootNodeName,nu ll,dtdFileName, null));
myNewDom.Append Child(myNewDom. ImportNode(xd.D ocumentElement, true));

myVReader = new XmlValidatingRe ader(new XmlTextReader(n ew
StringReader(my NewDom.InnerXml )));

myVReader.Valid ationType = 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
2256
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 individual fields, such as an "Email Validation Script" or a "Phone Validation Script". Is it ok to put all these scripts on page as they are or should they be joined in some way together to be one script? I'm a total JavaScript newbie and am completely...
5
17091
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 validating event and the user clicks another tab things get messy. Ideally, I think the best solution is not to leave a tab until the validating event has completed successfully. Thanks,
0
1997
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 accept on an insert, however, when it does a comparision validation it is failing. I have StartDate = comparing to an invisible textbox that contains todays date EndDate = comparing to StartDate needing to be >= SetupDate = comparing to StartDate...
3
3043
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. Page_ValidationSummaries has a length of 1 but there are no array entries. This is the line that fails: summary.style.display = "none";
9
3187
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... So the behavour is similar to a tab control. The user is expected to fill out required data on each of the panels before pressing a submit button which is visible from all panels. Problem I have is validating the data entered by the user. I...
2
2921
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". 'Measurement Validation (Range Validator) Dim MeasurementRangeValidator As New RangeValidator 'validate that the measure is numeric MeasurementRangeValidator.ControlToValidate = txtMeasurement.ID| MeasurementRangeValidator.Display =...
1
1837
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 myself ? Niclas
12
7925
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 it, it works every time! I even set it to True, but did a .Flush just before the error, and the error won't happen. It only happens when response.buffer is True and no .response.flush is issued. The error is a string variable turns-up empty...
2
2073
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 enabled so there is no postback. What can I hook into on the client side to execute other client side script (eg. show a hidden label or popup) if validation fails?
0
9588
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.