You can pretty much do that now with V3. There is a 'reuse validator' flag
on the parse() call. If you get the validator loaded up once, you can just
force the use of that validator on subsequent parses. The files being
parsed cannot have any internal subset if you do this, they can only have a
reference to an external DTD (or eventually schema.)
Now, that's not the same as 'use this one if you don't have one, otherwise
use the DTD you reference'. Its just a reuse of a previous validator.
We will provide some more flexibility in this area in the future, but there
is a fine line to walk here where if things get too lose, then people will
get bogged down in the complexity of options. But certainly, I feel that
being able to force a particular DTD to be used is not unreasonable. I'll
put that on the list of things.
And I already have on the list the ability to just parse a DTD separately
via the validator itself, without having any source document. So you could
use this capability to load up a DTD and then create the parser with that
DTD, and call parse always with the 'reuse' flag, so that that validator
content would always be used for validation without the overhead of parsing
the DTD.
Note that you can also use the 'entity resolver' creatively for this kind
of stuff. Every external entity (DTD included) is passed though the entity
resolver, and you have the chance to give us back an input source to
whatever you want. If you can recognize what type of entity it is, i.e. the
DTD, then you can override that any way you want.
----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
[EMAIL PROTECTED]
"Ed Hager" <[EMAIL PROTECTED]> on 12/21/99 08:51:15 AM
Please respond to [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
cc:
Subject: PROPOSAL: Document validation by overriding DTD.
I have just joined this discussion group so pardon me if I am suggesting
something that has previously been discussed...
I am going to use the term "DTD" but it should be interchangeable with
"schema" in my following discussion.
I would like to be able to validate a document against one or more DTD's
when the document itself contains no reference to a DTD. For example, I
might make the following call:
doc.isValid("c:\documents\myDTD.dtd");
Alternatively, maybe I could pass the DTD to the parser and the parser
would
use my DTD to validate the document. In either case, any DTD referenced by
the document would be ignored.
Here is a possible scenario that would use this functionality:
1. Parse and validate a document that references DTD1.
2. If the document is valid, validate the document against DTD2.
In this scenario, DTD2 represents a subset of DTD1.
So, I basically want to be able to validate a document against any DTD
without having to create a copy of the document that references the desired
DTD.
Thoughts? Is there some way to do this now and I have missed it?
eD
Ed Hager [EMAIL PROTECTED]