Groups | Blog | Home
all groups > dotnet xml > august 2007 >

dotnet xml : [VB] XML & DTD -Validation


Pepi
8/26/2007 10:34:13 AM
Hi,
I've got a problem.

Consider for a moment that there exists a URI to a DTD in an XML file.
Not very uncommon. Now, what happens if the remote server owner go
belly up and because of this the DTD vanishes? Will all XML docs of the
same type be rendered useless?

If not, how do you tell VB to use a different DTD with an old document
that already contains a URI to the DTD, _without_ altering the XML
document?

It seems I can't tell VB to skip the validation step. Everything I've
tried so far has failed. What I came up with was to delete the old URIs
from the XML document and replace them with new ones. This works, but
is an untidy way of doing it, and it makes the whole thing slower.

Any better ideas out there?

TIA
--
Martin Honnen
8/27/2007 12:00:00 AM
[quoted text, click to view]

Use a custom XmlResolver that resolves the URI to a local copy of the DTD.
See the property XmlResolver
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.XmlReaderSettings.XmlResolver.aspx>
of XmlReaderSettings or the property XmlResolver
<URL:http://msdn2.microsoft.com/en-us/library/System.Xml.XmlDocument.XmlResolver.aspx>
of XmlDocument.


--

Martin Honnen --- MVP XML
Pepi
8/27/2007 1:42:06 PM
On 27 aug 2007, Martin Honnen<mahotrash@yahoo.de>, had the following
to say to the folks in microsoft.public.dotnet.xml:

[quoted text, click to view]

Thanks. :-)

I have to think about this though, since I can't get it to work with
anything other than doc.XmlResolver = Nothing

I assume (from the speed it suddenly ran at) that nothing is validated.
I can live with that, but it sure would be nice if it would use a local
DTD.
--
Martin Honnen
8/28/2007 12:00:00 AM
[quoted text, click to view]

Then subclass XmlUrlResolver with a class that maps the system
identifier of the URL to a local copy. Then use an instance of that
class as doc.XmlResolver.


--

Martin Honnen --- MVP XML
Pepi
9/2/2007 10:36:36 AM
On 28 aug 2007, Martin Honnen<mahotrash@yahoo.de>, had the following
to say to the folks in microsoft.public.dotnet.xml:

Thanks for your reply. I'm sorry I'm late with a response, but I've
been away on a funeral.

[quoted text, click to view]

Sorry, now you've lost me. That's Chinese to me. I only started using
VB .NET about a month ago.

Here's what I have so far:

Dim doc as New XmlDocument
Dim Parts as XmlNodeList : Dim Part as XmlNode

Dim resolver As XmlUrlResolver = New XmlUrlResolver()
Dim myuri As New Uri("c:/temp/DTD/tss-1.9.dtd")

resolver.ResolveUri(myuri, "")
doc.XmlResolver = resolver
doc.Load(fInfo.CurrentFileName)

[...]

This doesn't work as I want it to, but I will try again later with
some more ideas.

Thanks for your help.
--
AddThis Social Bookmark Button