You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Henry Luo <he...@openmarket.com> on 2000/04/27 16:13:39 UTC
How to force the parser to use a specific DTD?
Is there any way to tell the DOM parser to use a given
DTD file, instead of the one specified in the <!DOCTYPE
line?
Also, is there a way to tell the parser to ignore the
internal DTD?
Thanks.
Re: How to force the parser to use a specific DTD?
Posted by Dean Roddey <dr...@charmedquark.com>.
For the first question, you have to use an entity resolver, which requires
that you know that its the DTD. For the second question, the answer is no.
It will never ignore the internal subset.
--------------------------
Dean Roddey
The CIDLib Class Libraries
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com
"Give me immortality, or give me death"
Re: How to force the parser to use a specific DTD?
Posted by Tom Jordahl <to...@allaire.com>.
Henry Luo wrote:
> Is there any way to tell the DOM parser to use a given
> DTD file, instead of the one specified in the <!DOCTYPE
> line?
> Also, is there a way to tell the parser to ignore the
> internal DTD?
I can answer this so Dean wont have to post his answer again:
Dean Roddey wrote:
> In your program, create a small in memory file that references your
> DTD (see the MemParse sample) and parse it. This will load the
> validator with your DTD information. In subsequent parses,
> set the 'reuseValidator' flag on the parse() call. This will
> cause any DTD in the document to be ignored and the same data in
> the validator reused.
>
> NOTE: The file cannot have any internal subset or it will be
> considered an error (since that might have changed things in
> a way that we cannot easily forsee.) So the files must either
> have no DTD or just an external DTD. If they have an external
> DTD it will just not be parsed and validator will be left as is
> and used with whatever element, attr, etc... declarations are
> currently in it.
I am using this method successfully.
It does have the drawback of throwing an error if an internal
DTD is specified, but this is OK for me (though not great).
Maybe this is a good question to put in the FAQ list?
I still like the idea of an API to directly tell an instance
of the parser that *this* is the DTD you want to use, and
to ignore any and all others it might encounter in a document.
--
Tom Jordahl tomj@allaire.com
Allaire Corp. http://www.allaire.com