Re: [xml] using xmlSetExternalEntityLoader to return internally generated XML documents
- From: Rush Manbert <rush manbert com>
- To: Nathan Day <nathan_day mac com>
- Cc: xml gnome org
- Subject: Re: [xml] using xmlSetExternalEntityLoader to return internally generated XML documents
- Date: Tue, 31 Jul 2007 10:06:59 -0700
Nathan Day wrote:
I have a lot of XML documents that are generated using the tree API or
the XSLT API and I want to be able to refer to them in other XML
document within LIBXML2 through URL's (xincludes, xslt imports,
includes, document(), etc.). Looking at the documentation
xmlSetExternalEntityLoader is what I want but I am not sure what I am
supposed to do next. I guess I am supposed to create a
xmlParserInputPtr but how do I create one for an XML document, is that
what xmlNewEntityInputStream is for, in which case how do I create a
xmlEntity.
The xsltproc utility does this, so get its source and see what it does.
I actually hacked its init code to use in my app, and hacked the entity
loader to call my own code.
Another question I have,
I have some XSL transformations that take a long time, up to 6 seconds
in some cases, fortunately large parts of these transformations produce
the same result. So what I want to do is create a mechanism so that
when a XML document is being serialised into a string I can have my own
call back function called at particular points so that I can insert
previously serialised text. I suppose I could just insert a big text
element into the xml document another possibility is to serialise the
document my self, this is for generating HTML, would this be difficult.
It's not too hard to walk the DOM tree and make callbacks for each node,
or for some filtered subset. Then you can insert nodes (and entire
subtrees) into the DOM tree before you serialize the content. However,
that means that you need to know the DOM representation of the stuff
you're trying to insert, so you would need to try to generate it then
save off the representation (I'm assuming you want to cache a
transformation result, then use it in subsequent documents.), so it
might not be useful for you. And you might not even be creating a DOM
tree. Maybe the SAX interface would be useful? (I haven't used it.)
Hope it helps,
Rush
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]