mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-25 13:49:22 +03:00
440226 Add xmlXIncludeProcessTreeFlagsData API
* xinclude.c include/libxml/xinclude.h: new function similar to xmlXIncludeProcessFlagsData but operating on a subtree
This commit is contained in:
committed by
Daniel Veillard
parent
56a03035bf
commit
b9590e9cd2
@ -89,18 +89,22 @@ typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
|
||||
/*
|
||||
* standalone processing
|
||||
*/
|
||||
XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcess (xmlDocPtr doc);
|
||||
XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessFlags (xmlDocPtr doc,
|
||||
int flags);
|
||||
XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessFlagsData(xmlDocPtr doc,
|
||||
int flags,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,
|
||||
int flags,
|
||||
void *data);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTree (xmlNodePtr tree);
|
||||
XMLPUBFUN int XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
|
||||
int flags);
|
||||
/*
|
||||
|
51
xinclude.c
51
xinclude.c
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user