local DTD but not inlined

I have read many postings on the subject but I am still confused.
I want to supply an application that can validate XML.
I am using the Microsoft parser.

How do I supply a DOCTYPE such that
1) it is not inlined
2) the application will not access the URL (it might be offline)

For example:
Where with a MS parser, will the following DTD be searched, assuming no
internet connection?

Who is Participating?
unikenConnect With a Mentor Commented:
You can't tell MSXML to use an alternative DTD. It automatically uses the one declared in the DOCTYPE declaration.

The document object has a doctype property exposed but it is READ ONLY. So you can't change the doctype declaration after you have loaded the XML file into the DOM either.

The only way to achieve what you want is to change the actual text of the doctype declaration programatically before loading into MSXML.

The MS parser doesn't try to look anywhere else if the specified URL is not reachable. (nor do any others I know)


In this case, your application needs
to handle the 'offline' scenario.

When it is offline, you will probably
do parse the XML without validating
against the DTD.

Hope this helps
mcoAuthor Commented:
Are you sure it is not possible to validate
against an alternative offline local DTD.
I am quite sure it is possible.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

sorry, I miss the part about alternative.

I will withdrew my answer.


Write the DTD and save that as .DTD file. And in the XML file, which would be validated by the DTD written previously, you have to specify in the following way to vaidate that XML file,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CompanyOrders SYSTEM "xxx.dtd">

The above will work perfectly. And the DTD file should be saved in the directory of that XML file for the above syntax. If the DTD was there some where else, then simply specify the path within the quotes as,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CompanyOrders SYSTEM "yyy/zzz/xxx.dtd">

This will work as offline DTD. Hope this was what you want.

mcoAuthor Commented:
Thanks, but this does not solve the problem.
What you are suggesting is that the XML will be written especially to look at the local file.
I want the XML to include the correct global
URL, but that my application would validate it against a local copy, in order that it would work also while offline.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.