HighTechTalks DotNet Forums  

Validating Xml document with !DOCTYPE in it?

Dotnet XML microsoft.public.dotnet.xml


Discuss Validating Xml document with !DOCTYPE in it? in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mads Bondo Dydensborg
 
Posts: n/a

Default Validating Xml document with !DOCTYPE in it? - 12-13-2007 , 09:25 AM






Hi there

I have a schema (xsd) that I can figure out to validate Xml docs against.

The documents however, also contain a DOCTYPE declaration. I would like for
my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it throws. If
I enabled the Dtd support (ProhibitDtd = false), it tries to retrieve the
URL. I have given it an XmlSecureResolver without any URL, and then it
throws...

So, it seems I can:

- have the validating XmLReader throw when it encounters an DOCTYPE
or
- have it try to fetch the URL of the DOCTYPE

I just want it to ignore it...

Any advice?

Regards

Mads

--
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34

Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Validating Xml document with !DOCTYPE in it? - 12-13-2007 , 10:42 AM






Mads Bondo Dydensborg wrote:
Quote:
Hi there

I have a schema (xsd) that I can figure out to validate Xml docs against.

The documents however, also contain a DOCTYPE declaration. I would like for
my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it throws. If
I enabled the Dtd support (ProhibitDtd = false), it tries to retrieve the
URL. I have given it an XmlSecureResolver without any URL, and then it
throws...

So, it seems I can:

- have the validating XmLReader throw when it encounters an DOCTYPE
or
- have it try to fetch the URL of the DOCTYPE

I just want it to ignore it...

Any advice?
Please try to use XmlReaderSettings with XmlResolver set to null and
ProhibitDtd set to false, that should not load the DTD.

If you need the resolver for your schemas then you will have to subclass
XmlUrlResolver and override the methods to make sure the DTD is not loaded.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
  #3  
Old   
Mads Bondo Dydensborg
 
Posts: n/a

Default Re: Validating Xml document with !DOCTYPE in it? - 12-13-2007 , 10:48 AM



Mads Bondo Dydensborg wrote:

Quote:
I have a schema (xsd) that I can figure out to validate Xml docs against.

The documents however, also contain a DOCTYPE declaration. I would like
for my XmlReader to _ignore_ the DOCTYPE declaration. Currently, it
throws. If I enabled the Dtd support (ProhibitDtd = false), it tries to
retrieve the URL. I have given it an XmlSecureResolver without any URL,
and then it throws...
Seems using a null XmlResolver actually works - I thought from reading the
docs, that one would always have to supply a resolver, when the ProhibitDtd
was false.

Oh well - works for now.

Regards,

Mads

--
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34


Reply With Quote
  #4  
Old   
Mads Bondo Dydensborg
 
Posts: n/a

Default Re: Validating Xml document with !DOCTYPE in it? - 12-13-2007 , 02:15 PM



Martin Honnen wrote:

Quote:
I just want it to ignore it...

Any advice?

Please try to use XmlReaderSettings with XmlResolver set to null and
ProhibitDtd set to false, that should not load the DTD.
Thanks. I (mis)read the docs - it was my understanding that one needed a
non-null XmlResolver when ProhibitDtd was set to false.

Thanks again

Mads

--
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.