RE: [xml] DTDs



Thanks a lot for your answer ! I have some minor questions left :

This is how I handle it now: I require an external DTD 
declaration in 
the XML file. I also register an external entity loader 
with libxml2, 
which checks for the specifiy id/url, and provides the DTD from 
memory. Once loaded, I check the parse tree to make sure 
that indeed 
this external DTD declaration has been specified, and with 
the correct 
URL / id. Finally I have libxml2 validate the XML file.

Any comments on this procedure ?

  Fine, very close to catalogs. Another possibility is to not 
switch DTD parsing and have a (set of) preparsed DTD(s) and use
xmlValidateDtd() to check the documents against the DTD(s) 
after parsing.


Catalogs ? You mean the external entity load part ? I tried using
catalogs for this, but I could not find a way to build an in-memory
catalog. It always seems to require some file to start with. If I could
create an in-memory catalog, then I would map the DTD ID/URL to
something like "jar:...." or "res:..." (I already wrote the
corresponding protocol handlers). 

How would I preparse a DTD ? Looking through the API, I can't find
anything that would allow me to (a) create an "struct xmlDtd" from a
DTD, or better yet, load it from a serialized "struct xmlDtd".

Something else: I install my external entity loader using
xmlSetExternalEntityLoader(). Before calling this function, I remember
the previous loader using xmlGetExternalEntityLoader(), which I continue
to use in my loader if I don't handler the entity. The problem is that
this requires a global variable. I could not find a way to pass the
previous loader's function pointer as private (context) information to
my loader. The "context" argument to my the loader function only seems
to contain a pointer to the xmlDoc being created. Is there a way to
split xmlParseFile() in two steps ? Step 1: create an empty document,
and set some context information (how ?); Step 2: parse the file, and
make use of this context data in the entity loader ?

- Daniel




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]