From: Daniel Veillard (Daniel.Veillard@imag.fr)
Date: Wed Feb 07 2001 - 10:35:37 EST
On Wed, Feb 07, 2001 at 02:49:50PM +0000, Gary Pennington wrote:
>
> Hi,
>
> I have a document with an associated DTD. I validate it. I then
> programmatically make changes to the document, including adding new
> elements, updating attributes, etc...
>
> Now, before I write the document to disk I want to re-validate the
> document to ensure that it is still valid and no errors have been
> introduced. How to do this in libxml?
>
> I tried calling xmlValidateDocument,
yes, that's the right way,
> however it complained that IDs were
> already defined which means, I guess, that the data structures are still
> there from the previous validation and thus causing problems for the
> re-validation.
>
> I did a quick hack to set ids and refs to NULL in the document when
> calling xmlValidateDocument and this did the trick for me at the cost of
> a memory leak.
>
> I think the real answer is to find the core validation function(s) and
> do an xmlFreeIDTable and an xmlFreeRefTable whenever validation is
> called if the table pointers aren't null.
Right this should be done only at revalidation time.
> I'm not certain that this patch is catching all areas where it's
> required, so it needs some scrutiny. It's working fine for me in the
> scenario I descrbed above. I decided to put the check in xmlValidateRoot
> since I was pretty sure that this would be called whenever an entire
> document was validated, however it may be the wrong place for this
> check.
Yes I'm afraid that you would loose ID and REF tables when parsing
and validating at the very last step of the document validation, I'm
not 100% sure about this but I would prefer to avoid the risk :-).
This should be added only when one is about to revalidate a document.
So I added it at the beginning of xmlValidateDocument() and
xmlValidateDtd().
Patch enclosed, quick feedback on it would be welcome,
Daniel
-- Daniel Veillard | Red Hat Network http://redhat.com/products/network/ veillard@redhat.com | libxml Gnome XML toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
---- Message from the list xml@rpmfind.net Archived at : http://xmlsoft.org/messages/ to unsubscribe: echo "unsubscribe xml" | mail majordomo@rpmfind.net
This archive was generated by hypermail 2b29 : Wed Feb 07 2001 - 10:44:08 EST