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

DTD and XmlReaderSettings

Hajo,

I want to validate xml against DTD but I am not able to load DTD
schema.
My code looks like that:

XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.DTD;
settings.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
settings.Schemas.Add(null,@"C:\application.dtd");

and I at last line I always get this error:

'ELEMENT' is an unexpected token. The expected token is 'DOCTYPE'. Line
38, position 3.

Below I enclose 38th line of DTD.
<!ELEMENT eu-application:applicationform (
declaration
, application
, maa-particulars
, scientific-advice
, paediatric-program
, other-maa
, annexed-documents
)>

But DTD should be ok because XMLSpy says that is well-formed. Any idea
what it is wrong?
thanks in advance

Pawel Pabich

Nov 12 '05 #1
2 6495
I would like to add that I can not use <!Doctype> in xml because XML
schema can not be wrtitten to hard drive. It has to be supplied from
memory.

Pawel

Nov 12 '05 #2
XmlReaderSettings.Schemas property returns an XmlSchemaSet object that can
only accept W3C XML Schema and not DTDs.
If you have a DTD file, you should either specify the DTD as an internal
subset in the xml file itself or provide the dtd file name at the beginning
of your xml file.

<!DOCTYPE Root SYSTEM "application.dtd">
<Root>
<Content>
....
</Content>
</Root>

Or

<!DOCTYPE Root [
<!ELEMENT Content ANY>
]>
<Root>
<Content>
....
</Content>
</Root>
-Priya

<pa**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hajo,

I want to validate xml against DTD but I am not able to load DTD
schema.
My code looks like that:

XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.DTD;
settings.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
settings.Schemas.Add(null,@"C:\application.dtd");

and I at last line I always get this error:

'ELEMENT' is an unexpected token. The expected token is 'DOCTYPE'. Line
38, position 3.

Below I enclose 38th line of DTD.
<!ELEMENT eu-application:applicationform (
declaration
, application
, maa-particulars
, scientific-advice
, paediatric-program
, other-maa
, annexed-documents
)>

But DTD should be ok because XMLSpy says that is well-formed. Any idea
what it is wrong?
thanks in advance

Pawel Pabich

Nov 12 '05 #3

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

Similar topics

1
by: peter.moss | last post by:
I have an XML schema and I am trying to validate any XML document sent against it. Here's some of the code: XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); ...
0
by: Jen | last post by:
My main question: "How can I get a TextReader or Stream object from an existing XmlReader?". Read on for more: I have an existing XmlReader. Let's call it reader1. I'm creating another reader,...
1
by: Mac | last post by:
I'm trying to validate input from an xml source to a dataset in dotnet2.0. As far as I can see, type errors correctly cause an exception, but values that are the correct type but do not satisify...
0
by: Simon Ovens | last post by:
Hi im trying to read a news feed that is generated from an aspx page on my server but it comes up with and unauthrised error. I have changed the perimssions on the aspx news feed generator to no...
2
by: ba.hons | last post by:
Hi I have been tring to use some of the following classes which are new in ..net version 2 from what i have read on the MSDN the following should be supported XmlReaderSettings settings = new...
2
by: Techno_Dex | last post by:
I have an issue with the EventHandler for the XmlReaderSettings object being called twice during validation and I'm a little stumpped as to why. The error message being given is the same error...
2
by: pnmcosta | last post by:
Hi, I'm fairly new to XML Schema validation. We have XML being imported that must validate against the following schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ...
4
by: Daniel S | last post by:
Hi, Here's my problem code: .... XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Document; settings.CheckCharacters = false;...
1
by: TonyHallett | last post by:
Hi All. The documentation states "Setting CheckCharacters to false turns off character checking for character entity references." I seem to be missing the point on this. Please can someone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.