return 0;
}
+/*!
+ * \internal
+ * \brief Process XML Inclusions (XInclude).
+ *
+ * XIncludes can result in new includes being inserted, so we need to reprocess
+ * until no changes are made or we encounter an error.
+ *
+ * \param doc the document to process
+ *
+ * \retval 0 if XInclude processing concluded successfully
+ * \retval -1 if an error occurred during XInclude processing
+ */
+static int process_xincludes(xmlDoc *doc)
+{
+ int res;
+
+ do {
+ res = xmlXIncludeProcess(doc);
+ } while (res > 0);
+
+ return res;
+}
+
struct ast_xml_doc *ast_xml_open(char *filename)
{
xmlDoc *doc;
}
/* process xinclude elements. */
- if (xmlXIncludeProcess(doc) < 0) {
+ if (process_xincludes(doc) < 0) {
xmlFreeDoc(doc);
return NULL;
}
if (!(doc = xmlParseMemory(buffer, (int) size))) {
/* process xinclude elements. */
- if (xmlXIncludeProcess(doc) < 0) {
+ if (process_xincludes(doc) < 0) {
xmlFreeDoc(doc);
return NULL;
}
return NULL;
}
- if (xmlXIncludeProcess(xml) < 0) {
+ if (process_xincludes(xml) < 0) {
xmlFreeDoc(xml);
return NULL;
}
return NULL;
}
- if (xmlXIncludeProcess(doc) < 0) {
+ if (process_xincludes(doc) < 0) {
xmlFreeDoc(doc);
return NULL;
}