Re: [xml] "detached" DTD's

Several weeks ago (3 dec 02) I asked how I could "patch up" a parsed
document, identifying ID attributes.  I needed to do this for interop
work so that Aleksey's xmlsec package could verify WS-Security

Daniel suggested a few things, including calling xmlValidateDtd
with empty error and warning callbacks.  That re-walks the tree,
which isn't very efficient, but it's probably good enough (the
crypto time will dominate).

So I do things like this
    xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
    xmlDtdPtr dtd = xmlParseDTD(NULL, (const xmlChar*)argv[++pos]);

And then later on I call this routine:

    static void noop_error(void* ctx, const char* msg, ...) {
    static void noop_warning(void* ctx, const char* msg, ...) {

    int findIDNodes(xmlDtdPtr dtd, xmlDocPtr doc) {
        xmlValidCtxt c = { 0 };

        c.error = noop_error;
        c.warning = noop_warning;
        xmlValidateDtd(&c, doc, dtd);
        return 0;

So, a couple of questions.  Should I set xmlLoadExtDtdDefaultValue
in findIDNodes, or before the DTD is loaded?  Should I bother
with noop_error and noop_warning, or just leave the pointers NULL?


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