mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +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
|
* standalone processing
|
||||||
*/
|
*/
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXIncludeProcess (xmlDocPtr doc);
|
xmlXIncludeProcess (xmlDocPtr doc);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXIncludeProcessFlags (xmlDocPtr doc,
|
xmlXIncludeProcessFlags (xmlDocPtr doc,
|
||||||
int flags);
|
int flags);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXIncludeProcessFlagsData(xmlDocPtr doc,
|
xmlXIncludeProcessFlagsData(xmlDocPtr doc,
|
||||||
int flags,
|
int flags,
|
||||||
void *data);
|
void *data);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
|
xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,
|
||||||
|
int flags,
|
||||||
|
void *data);
|
||||||
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXIncludeProcessTree (xmlNodePtr tree);
|
xmlXIncludeProcessTree (xmlNodePtr tree);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
|
xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
|
||||||
int flags);
|
int flags);
|
||||||
/*
|
/*
|
||||||
|
|||||||
51
xinclude.c
51
xinclude.c
@@ -2423,7 +2423,42 @@ xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) {
|
|||||||
ctxt->parseFlags = flags;
|
ctxt->parseFlags = flags;
|
||||||
return(0);
|
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:
|
* xmlXIncludeProcessFlagsData:
|
||||||
* @doc: an XML document
|
* @doc: an XML document
|
||||||
@@ -2440,25 +2475,13 @@ int
|
|||||||
xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) {
|
xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) {
|
||||||
xmlXIncludeCtxtPtr ctxt;
|
xmlXIncludeCtxtPtr ctxt;
|
||||||
xmlNodePtr tree;
|
xmlNodePtr tree;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (doc == NULL)
|
if (doc == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
tree = xmlDocGetRootElement(doc);
|
tree = xmlDocGetRootElement(doc);
|
||||||
if (tree == NULL)
|
if (tree == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
ctxt = xmlXIncludeNewContext(doc);
|
return(xmlXIncludeProcessTreeFlagsData(tree, flags, data));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user