Click here to Skip to main content
15,887,812 members
Home / Discussions / C#
   

C#

 
AnswerRe: Databinding Issue Pin
Pete O'Hanlon14-Sep-07 1:45
mvePete O'Hanlon14-Sep-07 1:45 
QuestionWPF UserControl Warning Pin
Michael O.14-Sep-07 1:18
Michael O.14-Sep-07 1:18 
QuestionDockPanel Pin
Mamphekgo Bahula14-Sep-07 1:06
Mamphekgo Bahula14-Sep-07 1:06 
QuestionAutomating the double click required to resize a datagrids columns Pin
c#_keithy14-Sep-07 0:56
c#_keithy14-Sep-07 0:56 
AnswerRe: Automating the double click required to resize a datagrids columns Pin
ElSpinos14-Sep-07 1:14
ElSpinos14-Sep-07 1:14 
AnswerRe: Automating the double click required to resize a datagrids columns Pin
AETaylor14-Sep-07 1:18
AETaylor14-Sep-07 1:18 
GeneralRe: Automating the double click required to resize a datagrids columns Pin
ElSpinos14-Sep-07 1:42
ElSpinos14-Sep-07 1:42 
QuestionValidation Error when Schema with Entities [modified] Pin
xfun55614-Sep-07 0:24
xfun55614-Sep-07 0:24 
Isn't there anyone to answer this?

Hi, I wrote a Schema Validator in C#.NET.

XmlTextReader R = new XmlTextReader(FileToParse); <br />
XmlValidatingReader V = new XmlValidatingReader(R); <br />
try <br />
{ <br />
XmlSchemaCollection xsc = new XmlSchemaCollection(); <br />
xsc.Add("", SchemaFile); <br />
V.Schemas.Add(xsc); <br />
V.EntityHandling = EntityHandling.ExpandEntities; <br />
V.ValidationEventHandler += new ValidationEventHandler(ShowValidationErrors); <br />
while (V.Read()) <br />
{ <br />
} <br />
//V.Close(); <br />
//MessageBox.Show("Validation Completed"); <br />
//R.Close(); <br />
} <br />
catch (XmlException xe) <br />
{ <br />
//Display exceptions <br />
} <br />
catch (XmlSchemaException xse) <br />
{ <br />
//Display exceptions <br />
} <br />
catch (Exception ee) <br />
{ <br />
//Display exceptions <br />
} <br />
finally <br />
{ <br />
V.Close(); <br />
MessageBox.Show("Validation Completed"); <br />
}


This works fine if the xml file DOES NOT contain entity declarations.

But, If the xml file contains any entity declaration (as below), the 'ValidationEventHandler' throws errors like
"Validation Error: The 'mytest' element is not declared.Line : 8 Position : 2"
"Validation Error: The 'articles' element is not declared.Line : 9 Position : 2", etc.....

How do I overcome this in C#.NET

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE mytest
[
a.'>
adv.'>

]>

<mytest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="X:\Schema\content.xsd">



-- modified at 7:56 Thursday 20th September, 2007
Questionabut dialog Pin
jason_mf13-Sep-07 23:26
jason_mf13-Sep-07 23:26 
AnswerRe: abut dialog Pin
Dave Kreskowiak14-Sep-07 6:29
mveDave Kreskowiak14-Sep-07 6:29 
QuestionHow to find the number of current window handles for a/my process. [modified] Pin
Martin#13-Sep-07 23:06
Martin#13-Sep-07 23:06 
AnswerRe: How to find the number of current window handles for a/my process. Pin
mav.northwind14-Sep-07 4:07
mav.northwind14-Sep-07 4:07 
GeneralRe: How to find the number of current window handles for a/my process. Pin
Martin#14-Sep-07 7:42
Martin#14-Sep-07 7:42 
GeneralRe: How to find the number of current window handles for a/my process. Pin
Martin#18-Sep-07 21:30
Martin#18-Sep-07 21:30 
QuestionRuntime Web Service Invocation Pin
MrEyes13-Sep-07 22:49
MrEyes13-Sep-07 22:49 
AnswerRe: Runtime Web Service Invocation Pin
ElSpinos14-Sep-07 0:15
ElSpinos14-Sep-07 0:15 
GeneralRe: Runtime Web Service Invocation Pin
MrEyes14-Sep-07 1:04
MrEyes14-Sep-07 1:04 
QuestionDatabase and SQL Pin
halalalal13-Sep-07 22:22
halalalal13-Sep-07 22:22 
AnswerRe: Database and SQL Pin
\laddie13-Sep-07 22:25
\laddie13-Sep-07 22:25 
QuestionSmart Phone Devices Pin
halalalal13-Sep-07 21:57
halalalal13-Sep-07 21:57 
AnswerRe: Smart Phone Devices Pin
Dave Kreskowiak14-Sep-07 6:27
mveDave Kreskowiak14-Sep-07 6:27 
Questionhow to display data in list view of mdi children form on search criteria Pin
mukesh choudhary13-Sep-07 21:52
mukesh choudhary13-Sep-07 21:52 
QuestionCreateDataReader from DataSet in Visual Studio 2003 Pin
Diego F.13-Sep-07 21:43
Diego F.13-Sep-07 21:43 
AnswerRe: CreateDataReader from DataSet in Visual Studio 2003 Pin
Pete O'Hanlon13-Sep-07 21:54
mvePete O'Hanlon13-Sep-07 21:54 
AnswerRe: CreateDataReader from DataSet in Visual Studio 2003 Pin
Colin Angus Mackay13-Sep-07 21:56
Colin Angus Mackay13-Sep-07 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.