version 1.1.1.2, 2013/07/22 01:22:18
|
version 1.1.1.3, 2014/06/15 19:53:31
|
Line 26
|
Line 26
|
#ifdef LIBXML_XINCLUDE_ENABLED |
#ifdef LIBXML_XINCLUDE_ENABLED |
#include <libxml/xinclude.h> |
#include <libxml/xinclude.h> |
|
|
|
#include "buf.h" |
|
|
#define XINCLUDE_MAX_DEPTH 40 |
#define XINCLUDE_MAX_DEPTH 40 |
|
|
Line 92 xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
Line 93 xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
|
|
/************************************************************************ |
/************************************************************************ |
* * |
* * |
* XInclude error handler * | * XInclude error handler * |
* * |
* * |
************************************************************************/ |
************************************************************************/ |
|
|
Line 412 xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
|
Line 413 xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
|
* xmlXIncludeParseFile: |
* xmlXIncludeParseFile: |
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @URL: the URL or file path |
* @URL: the URL or file path |
* | * |
* parse a document for XInclude |
* parse a document for XInclude |
*/ |
*/ |
static xmlDocPtr |
static xmlDocPtr |
Line 433 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
Line 434 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
* pass in the application data to the parser context. |
* pass in the application data to the parser context. |
*/ |
*/ |
pctxt->_private = ctxt->_private; |
pctxt->_private = ctxt->_private; |
| |
/* |
/* |
* try to ensure that new documents included are actually |
* try to ensure that new documents included are actually |
* built with the same dictionary as the including document. |
* built with the same dictionary as the including document. |
Line 446 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
Line 447 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
} |
} |
|
|
xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD); |
xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD); |
| |
inputStream = xmlLoadExternalEntity(URL, NULL, pctxt); |
inputStream = xmlLoadExternalEntity(URL, NULL, pctxt); |
if (inputStream == NULL) { |
if (inputStream == NULL) { |
xmlFreeParserCtxt(pctxt); |
xmlFreeParserCtxt(pctxt); |
Line 472 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
Line 473 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
pctxt->myDoc = NULL; |
pctxt->myDoc = NULL; |
} |
} |
xmlFreeParserCtxt(pctxt); |
xmlFreeParserCtxt(pctxt); |
| |
return(ret); |
return(ret); |
} |
} |
|
|
Line 480 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
Line 481 xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const ch
|
* xmlXIncludeAddNode: |
* xmlXIncludeAddNode: |
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @cur: the new node |
* @cur: the new node |
* | * |
* Add a new node to process to an XInclude context |
* Add a new node to process to an XInclude context |
*/ |
*/ |
static int |
static int |
Line 511 xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr
|
Line 512 xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr
|
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); |
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); |
if (href == NULL) { |
if (href == NULL) { |
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ |
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ |
if (href == NULL) | if (href == NULL) |
return(-1); |
return(-1); |
} |
} |
if ((href[0] == '#') || (href[0] == 0)) |
if ((href[0] == '#') || (href[0] == 0)) |
Line 655 xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr
|
Line 656 xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr
|
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @doc: the new document |
* @doc: the new document |
* @url: the associated URL |
* @url: the associated URL |
* | * |
* The XInclude recursive nature is handled at this point. |
* The XInclude recursive nature is handled at this point. |
*/ |
*/ |
static void |
static void |
Line 684 xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocP
|
Line 685 xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocP
|
/* |
/* |
* Copy the private user data |
* Copy the private user data |
*/ |
*/ |
newctxt->_private = ctxt->_private; | newctxt->_private = ctxt->_private; |
/* |
/* |
* Copy the existing document set |
* Copy the existing document set |
*/ |
*/ |
Line 749 xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocP
|
Line 750 xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocP
|
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @txt: the new text node |
* @txt: the new text node |
* @url: the associated URL |
* @url: the associated URL |
* | * |
* Add a new txtument to the list |
* Add a new txtument to the list |
*/ |
*/ |
static void |
static void |
Line 808 xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDo
|
Line 809 xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDo
|
* @target: the document target |
* @target: the document target |
* @source: the document source |
* @source: the document source |
* @elem: the element |
* @elem: the element |
* | * |
* Make a copy of the node while preserving the XInclude semantic |
* Make a copy of the node while preserving the XInclude semantic |
* of the Infoset copy |
* of the Infoset copy |
*/ |
*/ |
Line 835 xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr
|
Line 836 xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr
|
* @target: the document target |
* @target: the document target |
* @source: the document source |
* @source: the document source |
* @elem: the element list |
* @elem: the element list |
* | * |
* Make a copy of the node list while preserving the XInclude semantic |
* Make a copy of the node list while preserving the XInclude semantic |
* of the Infoset copy |
* of the Infoset copy |
*/ |
*/ |
Line 874 xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDo
|
Line 875 xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDo
|
static xmlNodePtr |
static xmlNodePtr |
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) { |
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) { |
int i; |
int i; |
if (cur == NULL) | if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) |
return(cur); | return(NULL); |
cur = cur->children; |
cur = cur->children; |
for (i = 0;i <= no;cur = cur->next) { |
for (i = 0;i <= no;cur = cur->next) { |
if (cur == NULL) | if (cur == NULL) |
return(cur); |
return(cur); |
if ((cur->type == XML_ELEMENT_NODE) || |
if ((cur->type == XML_ELEMENT_NODE) || |
(cur->type == XML_DOCUMENT_NODE) || |
(cur->type == XML_DOCUMENT_NODE) || |
Line 922 xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
Line 923 xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
return(NULL); |
return(NULL); |
start = (xmlNodePtr) range->user; |
start = (xmlNodePtr) range->user; |
|
|
if (start == NULL) | if ((start == NULL) || (start->type == XML_NAMESPACE_DECL)) |
return(NULL); |
return(NULL); |
end = range->user2; |
end = range->user2; |
if (end == NULL) |
if (end == NULL) |
return(xmlDocCopyNode(start, target, 1)); |
return(xmlDocCopyNode(start, target, 1)); |
|
if (end->type == XML_NAMESPACE_DECL) |
|
return(NULL); |
|
|
cur = start; |
cur = start; |
index1 = range->index; |
index1 = range->index; |
Line 985 xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
Line 988 xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
/* prune and return full set */ |
/* prune and return full set */ |
if (level == lastLevel) |
if (level == lastLevel) |
xmlAddNextSibling(last, tmp); |
xmlAddNextSibling(last, tmp); |
else | else |
xmlAddChild(last, tmp); |
xmlAddChild(last, tmp); |
return(list); |
return(list); |
} else { /* ending node not a text node */ |
} else { /* ending node not a text node */ |
Line 1289 xmlXIncludeMergeEntity(xmlEntityPtr ent, xmlXIncludeMe
|
Line 1292 xmlXIncludeMergeEntity(xmlEntityPtr ent, xmlXIncludeMe
|
if (prev != NULL) { |
if (prev != NULL) { |
if (ent->etype != prev->etype) |
if (ent->etype != prev->etype) |
goto error; |
goto error; |
| |
if ((ent->SystemID != NULL) && (prev->SystemID != NULL)) { |
if ((ent->SystemID != NULL) && (prev->SystemID != NULL)) { |
if (!xmlStrEqual(ent->SystemID, prev->SystemID)) |
if (!xmlStrEqual(ent->SystemID, prev->SystemID)) |
goto error; |
goto error; |
Line 1389 xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlD
|
Line 1392 xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlD
|
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @url: the associated URL |
* @url: the associated URL |
* @nr: the xinclude node number |
* @nr: the xinclude node number |
* | * |
* Load the document, and store the result in the XInclude context |
* Load the document, and store the result in the XInclude context |
* |
* |
* Returns 0 in case of success, -1 in case of failure |
* Returns 0 in case of success, -1 in case of failure |
Line 1413 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlC
|
Line 1416 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlC
|
*/ |
*/ |
uri = xmlParseURI((const char *)url); |
uri = xmlParseURI((const char *)url); |
if (uri == NULL) { |
if (uri == NULL) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_HREF_URI, |
XML_XINCLUDE_HREF_URI, |
"invalid value URI %s\n", url); |
"invalid value URI %s\n", url); |
return(-1); |
return(-1); |
Line 1431 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlC
|
Line 1434 xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlC
|
xmlFreeURI(uri); |
xmlFreeURI(uri); |
if (URL == NULL) { |
if (URL == NULL) { |
if (ctxt->incTab != NULL) |
if (ctxt->incTab != NULL) |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_HREF_URI, |
XML_XINCLUDE_HREF_URI, |
"invalid value URI %s\n", url); |
"invalid value URI %s\n", url); |
else |
else |
Line 1550 loaded:
|
Line 1553 loaded:
|
ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc, |
ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc, |
doc, doc->children); |
doc, doc->children); |
} |
} |
} | } |
#ifdef LIBXML_XPTR_ENABLED |
#ifdef LIBXML_XPTR_ENABLED |
else { |
else { |
/* |
/* |
Line 1568 loaded:
|
Line 1571 loaded:
|
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL); |
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL); |
} |
} |
if (xptrctxt == NULL) { |
if (xptrctxt == NULL) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_XPTR_FAILED, |
XML_XINCLUDE_XPTR_FAILED, |
"could not create XPointer context\n", NULL); |
"could not create XPointer context\n", NULL); |
xmlFree(URL); |
xmlFree(URL); |
Line 1594 loaded:
|
Line 1597 loaded:
|
case XPATH_POINT: |
case XPATH_POINT: |
case XPATH_USERS: |
case XPATH_USERS: |
case XPATH_XSLT_TREE: |
case XPATH_XSLT_TREE: |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_XPTR_RESULT, |
XML_XINCLUDE_XPTR_RESULT, |
"XPointer is not a range: #%s\n", |
"XPointer is not a range: #%s\n", |
fragment); |
fragment); |
Line 1636 loaded:
|
Line 1639 loaded:
|
continue; |
continue; |
|
|
case XML_ATTRIBUTE_NODE: |
case XML_ATTRIBUTE_NODE: |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_XPTR_RESULT, |
XML_XINCLUDE_XPTR_RESULT, |
"XPointer selects an attribute: #%s\n", |
"XPointer selects an attribute: #%s\n", |
fragment); |
fragment); |
set->nodeTab[i] = NULL; |
set->nodeTab[i] = NULL; |
continue; |
continue; |
case XML_NAMESPACE_DECL: |
case XML_NAMESPACE_DECL: |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_XPTR_RESULT, |
XML_XINCLUDE_XPTR_RESULT, |
"XPointer selects a namespace: #%s\n", |
"XPointer selects a namespace: #%s\n", |
fragment); |
fragment); |
Line 1658 loaded:
|
Line 1661 loaded:
|
case XML_ENTITY_DECL: |
case XML_ENTITY_DECL: |
case XML_XINCLUDE_START: |
case XML_XINCLUDE_START: |
case XML_XINCLUDE_END: |
case XML_XINCLUDE_END: |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_XPTR_RESULT, |
XML_XINCLUDE_XPTR_RESULT, |
"XPointer selects unexpected nodes: #%s\n", |
"XPointer selects unexpected nodes: #%s\n", |
fragment); |
fragment); |
Line 1704 loaded:
|
Line 1707 loaded:
|
*/ |
*/ |
curBase = xmlBuildRelativeURI(URL, ctxt->base); |
curBase = xmlBuildRelativeURI(URL, ctxt->base); |
if (curBase == NULL) { /* Error return */ |
if (curBase == NULL) { /* Error return */ |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_HREF_URI, |
XML_XINCLUDE_HREF_URI, |
"trying to build relative URI from %s\n", URL); |
"trying to build relative URI from %s\n", URL); |
} else { |
} else { |
Line 1745 loaded:
|
Line 1748 loaded:
|
xmlChar *relBase; |
xmlChar *relBase; |
relBase = xmlBuildURI(xmlBase, base); |
relBase = xmlBuildURI(xmlBase, base); |
if (relBase == NULL) { /* error */ |
if (relBase == NULL) { /* error */ |
xmlXIncludeErr(ctxt, | xmlXIncludeErr(ctxt, |
ctxt->incTab[nr]->ref, |
ctxt->incTab[nr]->ref, |
XML_XINCLUDE_HREF_URI, |
XML_XINCLUDE_HREF_URI, |
"trying to rebuild base from %s\n", |
"trying to rebuild base from %s\n", |
Line 1782 loaded:
|
Line 1785 loaded:
|
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @url: the associated URL |
* @url: the associated URL |
* @nr: the xinclude node number |
* @nr: the xinclude node number |
* | * |
* Load the content, and store the result in the XInclude context |
* Load the content, and store the result in the XInclude context |
* |
* |
* Returns 0 in case of success, -1 in case of failure |
* Returns 0 in case of success, -1 in case of failure |
Line 1798 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
Line 1801 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
xmlCharEncoding enc = (xmlCharEncoding) 0; |
xmlCharEncoding enc = (xmlCharEncoding) 0; |
xmlParserCtxtPtr pctxt; |
xmlParserCtxtPtr pctxt; |
xmlParserInputPtr inputStream; |
xmlParserInputPtr inputStream; |
|
int xinclude_multibyte_fallback_used = 0; |
|
|
/* |
/* |
* Check the URL and remove any fragment identifier |
* Check the URL and remove any fragment identifier |
Line 1828 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
Line 1832 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
* directly through ctxt->doc. |
* directly through ctxt->doc. |
*/ |
*/ |
if (URL[0] == 0) { |
if (URL[0] == 0) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_TEXT_DOCUMENT, |
XML_XINCLUDE_TEXT_DOCUMENT, |
"text serialization of document not available\n", NULL); |
"text serialization of document not available\n", NULL); |
xmlFree(URL); |
xmlFree(URL); |
Line 1894 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
Line 1898 xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlC
|
/* |
/* |
* Scan all chars from the resource and add the to the node |
* Scan all chars from the resource and add the to the node |
*/ |
*/ |
|
xinclude_multibyte_fallback: |
while (xmlParserInputBufferRead(buf, 128) > 0) { |
while (xmlParserInputBufferRead(buf, 128) > 0) { |
int len; |
int len; |
const xmlChar *content; |
const xmlChar *content; |
|
|
content = xmlBufferContent(buf->buffer); | content = xmlBufContent(buf->buffer); |
len = xmlBufferLength(buf->buffer); | len = xmlBufLength(buf->buffer); |
for (i = 0;i < len;) { |
for (i = 0;i < len;) { |
int cur; |
int cur; |
int l; |
int l; |
|
|
cur = xmlStringCurrentChar(NULL, &content[i], &l); |
cur = xmlStringCurrentChar(NULL, &content[i], &l); |
if (!IS_CHAR(cur)) { |
if (!IS_CHAR(cur)) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | /* Handle splitted multibyte char at buffer boundary */ |
XML_XINCLUDE_INVALID_CHAR, | if (((len - i) < 4) && (!xinclude_multibyte_fallback_used)) { |
"%s contains invalid char\n", URL); | xinclude_multibyte_fallback_used = 1; |
xmlFreeParserInputBuffer(buf); | xmlBufShrink(buf->buffer, i); |
xmlFree(URL); | goto xinclude_multibyte_fallback; |
return(-1); | } else { |
| xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
| XML_XINCLUDE_INVALID_CHAR, |
| "%s contains invalid char\n", URL); |
| xmlFreeParserInputBuffer(buf); |
| xmlFree(URL); |
| return(-1); |
| } |
} else { |
} else { |
|
xinclude_multibyte_fallback_used = 0; |
xmlNodeAddContentLen(node, &content[i], l); |
xmlNodeAddContentLen(node, &content[i], l); |
} |
} |
i += l; |
i += l; |
} |
} |
xmlBufferShrink(buf->buffer, len); | xmlBufShrink(buf->buffer, len); |
} |
} |
xmlFreeParserCtxt(pctxt); |
xmlFreeParserCtxt(pctxt); |
xmlXIncludeAddTxt(ctxt, node, URL); |
xmlXIncludeAddTxt(ctxt, node, URL); |
Line 1937 loaded:
|
Line 1950 loaded:
|
* @ctxt: the XInclude context |
* @ctxt: the XInclude context |
* @fallback: the fallback node |
* @fallback: the fallback node |
* @nr: the xinclude node number |
* @nr: the xinclude node number |
* | * |
* Load the content of the fallback node, and store the result |
* Load the content of the fallback node, and store the result |
* in the XInclude context |
* in the XInclude context |
* |
* |
Line 1947 static int
|
Line 1960 static int
|
xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) { |
xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) { |
xmlXIncludeCtxtPtr newctxt; |
xmlXIncludeCtxtPtr newctxt; |
int ret = 0; |
int ret = 0; |
| |
if ((fallback == NULL) || (ctxt == NULL)) | if ((fallback == NULL) || (fallback->type == XML_NAMESPACE_DECL) || |
| (ctxt == NULL)) |
return(-1); |
return(-1); |
if (fallback->children != NULL) { |
if (fallback->children != NULL) { |
/* |
/* |
Line 2033 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
Line 2047 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); |
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF); |
if (href == NULL) { |
if (href == NULL) { |
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ |
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ |
if (href == NULL) | if (href == NULL) |
return(-1); |
return(-1); |
} |
} |
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); |
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); |
Line 2078 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
Line 2092 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
xmlFree(eschref); |
xmlFree(eschref); |
} |
} |
if (URI == NULL) { |
if (URI == NULL) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL); |
XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL); |
if (parse != NULL) |
if (parse != NULL) |
xmlFree(parse); |
xmlFree(parse); |
Line 2111 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
Line 2125 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
* Restore the original base before checking for fallback |
* Restore the original base before checking for fallback |
*/ |
*/ |
ctxt->base = oldBase; |
ctxt->base = oldBase; |
| |
if (ret < 0) { |
if (ret < 0) { |
xmlNodePtr children; |
xmlNodePtr children; |
|
|
Line 2129 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
Line 2143 xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
((xmlStrEqual(children->ns->href, XINCLUDE_NS)) || |
((xmlStrEqual(children->ns->href, XINCLUDE_NS)) || |
(xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) { |
(xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) { |
ret = xmlXIncludeLoadFallback(ctxt, children, nr); |
ret = xmlXIncludeLoadFallback(ctxt, children, nr); |
if (ret == 0) | if (ret == 0) |
break; |
break; |
} |
} |
children = children->next; |
children = children->next; |
} |
} |
} |
} |
if (ret < 0) { |
if (ret < 0) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_NO_FALLBACK, |
XML_XINCLUDE_NO_FALLBACK, |
"could not load %s, and no fallback was found\n", |
"could not load %s, and no fallback was found\n", |
URI); |
URI); |
Line 2174 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
Line 2188 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
if ((nr < 0) || (nr >= ctxt->incNr)) |
if ((nr < 0) || (nr >= ctxt->incNr)) |
return(-1); |
return(-1); |
cur = ctxt->incTab[nr]->ref; |
cur = ctxt->incTab[nr]->ref; |
if (cur == NULL) | if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) |
return(-1); |
return(-1); |
|
|
/* |
/* |
Line 2205 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
Line 2219 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
tmp = tmp->next; |
tmp = tmp->next; |
} |
} |
if (nb_elem > 1) { |
if (nb_elem > 1) { |
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, | xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref, |
XML_XINCLUDE_MULTIPLE_ROOT, |
XML_XINCLUDE_MULTIPLE_ROOT, |
"XInclude error: would result in multiple root nodes\n", |
"XInclude error: would result in multiple root nodes\n", |
NULL); |
NULL); |
Line 2252 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
Line 2266 xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr
|
} |
} |
} |
} |
|
|
| |
return(0); |
return(0); |
} |
} |
|
|
Line 2349 xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
Line 2363 xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPt
|
int ret = 0; |
int ret = 0; |
int i, start; |
int i, start; |
|
|
if ((doc == NULL) || (tree == NULL)) | if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL)) |
return(-1); |
return(-1); |
if (ctxt == NULL) |
if (ctxt == NULL) |
return(-1); |
return(-1); |
Line 2463 xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int f
|
Line 2477 xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int f
|
xmlXIncludeCtxtPtr ctxt; |
xmlXIncludeCtxtPtr ctxt; |
int ret = 0; |
int ret = 0; |
|
|
if ((tree == NULL) || (tree->doc == NULL)) | if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) || |
| (tree->doc == NULL)) |
return(-1); |
return(-1); |
|
|
ctxt = xmlXIncludeNewContext(tree->doc); |
ctxt = xmlXIncludeNewContext(tree->doc); |
Line 2548 xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags
|
Line 2563 xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags
|
xmlXIncludeCtxtPtr ctxt; |
xmlXIncludeCtxtPtr ctxt; |
int ret = 0; |
int ret = 0; |
|
|
if ((tree == NULL) || (tree->doc == NULL)) | if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) || |
| (tree->doc == NULL)) |
return(-1); |
return(-1); |
ctxt = xmlXIncludeNewContext(tree->doc); |
ctxt = xmlXIncludeNewContext(tree->doc); |
if (ctxt == NULL) |
if (ctxt == NULL) |
Line 2592 int
|
Line 2608 int
|
xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { |
xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { |
int ret = 0; |
int ret = 0; |
|
|
if ((node == NULL) || (node->doc == NULL) || (ctxt == NULL)) | if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || |
| (node->doc == NULL) || (ctxt == NULL)) |
return(-1); |
return(-1); |
ret = xmlXIncludeDoProcess(ctxt, node->doc, node); |
ret = xmlXIncludeDoProcess(ctxt, node->doc, node); |
if ((ret >= 0) && (ctxt->nbErrors > 0)) |
if ((ret >= 0) && (ctxt->nbErrors > 0)) |