[xml] Identifying the source file for an xi inclusion

I am processing a document which contains nested inclusions using
xi:include.  How can I tell the source file from which a given node was
included into the document?

I'd like this in order to be able to accurately report on error
locations.  What I have right now is:

static char *
nodeLocation(xmlNode *node)
    xmlDoc *doc = node->doc;
    return newstr("%s:%d (element %s)", doc->URL, node->line, node->name);

Which allows me to build a nice backtrace like this:

Unhandled Exception 49(XML_PROCESSING_ERROR): raised at test/check_params.c:519
--> Exception 49:  No processor defined for skit:let
at ./templates/postgres/extract.xml:5 (element let)
at ./templates/postgres/extract.xml:3 (element inclusion)
at ./templates/postgres/extract.xml:8 (element runsql)
at ./templates/postgres/extract.xml:4 (element cluster)
at ./templates/postgres/extract.xml:3 (element inclusion)
at ./templates/postgres/extract.xml:22 (element dump)
at ./templates/postgres/extract.xml:21 (element runsql)

The line numbers are accurate within each document but the URL (from
doc->URL) gives me only the URL of the root document and not the
included ones.

Any suggestions/help would be appreciated.



Attachment: signature.asc
Description: This is a digitally signed message part

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