diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2009-08-24 19:45:54 +0200 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2009-08-24 19:45:54 +0200 |
commit | b9590e9cd27992e5b5de01fd1adfffac4156a48b (patch) | |
tree | d5c03c672b0151910a9db5eafaf4c2de1705cb34 /xinclude.c | |
parent | 56a03035bf94defaf0777db54db59530146f5f9b (diff) | |
download | libxml2-b9590e9cd27992e5b5de01fd1adfffac4156a48b.tar.gz |
440226 Add xmlXIncludeProcessTreeFlagsData API
* xinclude.c include/libxml/xinclude.h: new function similar to
xmlXIncludeProcessFlagsData but operating on a subtree
Diffstat (limited to 'xinclude.c')
-rw-r--r-- | xinclude.c | 51 |
1 files changed, 37 insertions, 14 deletions
@@ -2423,7 +2423,42 @@ xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) { ctxt->parseFlags = flags; return(0); } - + +/** + * xmlXIncludeProcessTreeFlagsData: + * @tree: an XML node + * @flags: a set of xmlParserOption used for parsing XML includes + * @data: application data that will be passed to the parser context + * in the _private field of the parser context(s) + * + * Implement the XInclude substitution on the XML node @tree + * + * Returns 0 if no substitution were done, -1 if some processing failed + * or the number of substitutions done. + */ + +int +xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) { + xmlXIncludeCtxtPtr ctxt; + int ret = 0; + + if ((tree == NULL) || (tree->doc == NULL)) + return(-1); + + ctxt = xmlXIncludeNewContext(tree->doc); + if (ctxt == NULL) + return(-1); + ctxt->_private = data; + ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL); + xmlXIncludeSetFlags(ctxt, flags); + ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree); + if ((ret >= 0) && (ctxt->nbErrors > 0)) + ret = -1; + + xmlXIncludeFreeContext(ctxt); + return(ret); +} + /** * xmlXIncludeProcessFlagsData: * @doc: an XML document @@ -2440,25 +2475,13 @@ int xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) { xmlXIncludeCtxtPtr ctxt; xmlNodePtr tree; - int ret = 0; if (doc == NULL) return(-1); tree = xmlDocGetRootElement(doc); if (tree == NULL) return(-1); - ctxt = xmlXIncludeNewContext(doc); - if (ctxt == NULL) - return(-1); - ctxt->_private = data; - ctxt->base = xmlStrdup((xmlChar *)doc->URL); - xmlXIncludeSetFlags(ctxt, flags); - ret = xmlXIncludeDoProcess(ctxt, doc, tree); - if ((ret >= 0) && (ctxt->nbErrors > 0)) - ret = -1; - - xmlXIncludeFreeContext(ctxt); - return(ret); + return(xmlXIncludeProcessTreeFlagsData(tree, flags, data)); } /** |