Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/libxml/xinclude.c

Issue 2951008: Update libxml to 2.7.7. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * xinclude.c : Code to implement XInclude processing 2 * xinclude.c : Code to implement XInclude processing
3 * 3 *
4 * World Wide Web Consortium W3C Last Call Working Draft 10 November 2003 4 * World Wide Web Consortium W3C Last Call Working Draft 10 November 2003
5 * http://www.w3.org/TR/2003/WD-xinclude-20031110 5 * http://www.w3.org/TR/2003/WD-xinclude-20031110
6 * 6 *
7 * See Copyright for the status of this software. 7 * See Copyright for the status of this software.
8 * 8 *
9 * daniel@veillard.com 9 * daniel@veillard.com
10 */ 10 */
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 /* 432 /*
433 * pass in the application data to the parser context. 433 * pass in the application data to the parser context.
434 */ 434 */
435 pctxt->_private = ctxt->_private; 435 pctxt->_private = ctxt->_private;
436 436
437 /* 437 /*
438 * try to ensure that new documents included are actually 438 * try to ensure that new documents included are actually
439 * built with the same dictionary as the including document. 439 * built with the same dictionary as the including document.
440 */ 440 */
441 if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL) && 441 if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL)) {
442 (pctxt->dict != NULL)) { 442 if (pctxt->dict != NULL)
443 » xmlDictFree(pctxt->dict); 443 xmlDictFree(pctxt->dict);
444 pctxt->dict = ctxt->doc->dict; 444 pctxt->dict = ctxt->doc->dict;
445 xmlDictReference(pctxt->dict); 445 xmlDictReference(pctxt->dict);
446 } 446 }
447 447
448 xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD); 448 xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD);
449 449
450 inputStream = xmlLoadExternalEntity(URL, NULL, pctxt); 450 inputStream = xmlLoadExternalEntity(URL, NULL, pctxt);
451 if (inputStream == NULL) { 451 if (inputStream == NULL) {
452 xmlFreeParserCtxt(pctxt); 452 xmlFreeParserCtxt(pctxt);
453 return(NULL); 453 return(NULL);
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url); 791 ctxt->txturlTab[ctxt->txtNr] = xmlStrdup(url);
792 ctxt->txtNr++; 792 ctxt->txtNr++;
793 } 793 }
794 794
795 /************************************************************************ 795 /************************************************************************
796 * * 796 * *
797 * Node copy with specific semantic * 797 * Node copy with specific semantic *
798 * * 798 * *
799 ************************************************************************/ 799 ************************************************************************/
800 800
801 static xmlNodePtr
802 xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
803 xmlDocPtr source, xmlNodePtr elem);
804
801 /** 805 /**
802 * xmlXIncludeCopyNode: 806 * xmlXIncludeCopyNode:
803 * @ctxt: the XInclude context 807 * @ctxt: the XInclude context
804 * @target: the document target 808 * @target: the document target
805 * @source: the document source 809 * @source: the document source
806 * @elem: the element 810 * @elem: the element
807 * 811 *
808 * Make a copy of the node while preserving the XInclude semantic 812 * Make a copy of the node while preserving the XInclude semantic
809 * of the Infoset copy 813 * of the Infoset copy
810 */ 814 */
811 static xmlNodePtr 815 static xmlNodePtr
812 xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target, 816 xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
813 xmlDocPtr source, xmlNodePtr elem) { 817 xmlDocPtr source, xmlNodePtr elem) {
814 xmlNodePtr result = NULL; 818 xmlNodePtr result = NULL;
815 819
816 if ((ctxt == NULL) || (target == NULL) || (source == NULL) || 820 if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
817 (elem == NULL)) 821 (elem == NULL))
818 return(NULL); 822 return(NULL);
819 if (elem->type == XML_DTD_NODE) 823 if (elem->type == XML_DTD_NODE)
820 return(NULL); 824 return(NULL);
821 result = xmlDocCopyNode(elem, target, 1); 825 if (elem->type == XML_DOCUMENT_NODE)
826 » result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children);
827 else
828 result = xmlDocCopyNode(elem, target, 1);
822 return(result); 829 return(result);
823 } 830 }
824 831
825 /** 832 /**
826 * xmlXIncludeCopyNodeList: 833 * xmlXIncludeCopyNodeList:
827 * @ctxt: the XInclude context 834 * @ctxt: the XInclude context
828 * @target: the document target 835 * @target: the document target
829 * @source: the document source 836 * @source: the document source
830 * @elem: the element list 837 * @elem: the element list
831 * 838 *
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 const xmlChar *content = cur->content; 967 const xmlChar *content = cur->content;
961 int len; 968 int len;
962 969
963 if (content == NULL) { 970 if (content == NULL) {
964 tmp = xmlNewTextLen(NULL, 0); 971 tmp = xmlNewTextLen(NULL, 0);
965 } else { 972 } else {
966 len = index2; 973 len = index2;
967 if ((cur == start) && (index1 > 1)) { 974 if ((cur == start) && (index1 > 1)) {
968 content += (index1 - 1); 975 content += (index1 - 1);
969 len -= (index1 - 1); 976 len -= (index1 - 1);
970 index1 = 0;
971 } else { 977 } else {
972 len = index2; 978 len = index2;
973 } 979 }
974 tmp = xmlNewTextLen(content, len); 980 tmp = xmlNewTextLen(content, len);
975 } 981 }
976 /* single sub text node selection */ 982 /* single sub text node selection */
977 if (list == NULL) 983 if (list == NULL)
978 return(tmp); 984 return(tmp);
979 /* prune and return full set */ 985 /* prune and return full set */
980 if (level == lastLevel) 986 if (level == lastLevel)
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 xmlXPathFreeObject(xptr); 1677 xmlXPathFreeObject(xptr);
1672 } 1678 }
1673 xmlXPathFreeContext(xptrctxt); 1679 xmlXPathFreeContext(xptrctxt);
1674 xmlFree(fragment); 1680 xmlFree(fragment);
1675 } 1681 }
1676 #endif 1682 #endif
1677 1683
1678 /* 1684 /*
1679 * Do the xml:base fixup if needed 1685 * Do the xml:base fixup if needed
1680 */ 1686 */
1681 if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/'))) { 1687 if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/')) &&
1688 (!(ctxt->parseFlags & XML_PARSE_NOBASEFIX)) &&
1689 » (!(doc->parseFlags & XML_PARSE_NOBASEFIX))) {
1682 xmlNodePtr node; 1690 xmlNodePtr node;
1683 xmlChar *base; 1691 xmlChar *base;
1684 xmlChar *curBase; 1692 xmlChar *curBase;
1685 1693
1686 /* 1694 /*
1687 * The base is only adjusted if "necessary", i.e. if the xinclude node 1695 * The base is only adjusted if "necessary", i.e. if the xinclude node
1688 * has a base specified, or the URL is relative 1696 * has a base specified, or the URL is relative
1689 */ 1697 */
1690 base = xmlGetNsProp(ctxt->incTab[nr]->ref, BAD_CAST "base", 1698 base = xmlGetNsProp(ctxt->incTab[nr]->ref, BAD_CAST "base",
1691 XML_XML_NAMESPACE); 1699 XML_XML_NAMESPACE);
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 * 2422 *
2415 * Returns 0 in case of success and -1 in case of error. 2423 * Returns 0 in case of success and -1 in case of error.
2416 */ 2424 */
2417 int 2425 int
2418 xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) { 2426 xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) {
2419 if (ctxt == NULL) 2427 if (ctxt == NULL)
2420 return(-1); 2428 return(-1);
2421 ctxt->parseFlags = flags; 2429 ctxt->parseFlags = flags;
2422 return(0); 2430 return(0);
2423 } 2431 }
2424 2432
2433 /**
2434 * xmlXIncludeProcessTreeFlagsData:
2435 * @tree: an XML node
2436 * @flags: a set of xmlParserOption used for parsing XML includes
2437 * @data: application data that will be passed to the parser context
2438 * in the _private field of the parser context(s)
2439 *
2440 * Implement the XInclude substitution on the XML node @tree
2441 *
2442 * Returns 0 if no substitution were done, -1 if some processing failed
2443 * or the number of substitutions done.
2444 */
2445
2446 int
2447 xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) {
2448 xmlXIncludeCtxtPtr ctxt;
2449 int ret = 0;
2450
2451 if ((tree == NULL) || (tree->doc == NULL))
2452 return(-1);
2453
2454 ctxt = xmlXIncludeNewContext(tree->doc);
2455 if (ctxt == NULL)
2456 return(-1);
2457 ctxt->_private = data;
2458 ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL);
2459 xmlXIncludeSetFlags(ctxt, flags);
2460 ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree);
2461 if ((ret >= 0) && (ctxt->nbErrors > 0))
2462 ret = -1;
2463
2464 xmlXIncludeFreeContext(ctxt);
2465 return(ret);
2466 }
2467
2425 /** 2468 /**
2426 * xmlXIncludeProcessFlagsData: 2469 * xmlXIncludeProcessFlagsData:
2427 * @doc: an XML document 2470 * @doc: an XML document
2428 * @flags: a set of xmlParserOption used for parsing XML includes 2471 * @flags: a set of xmlParserOption used for parsing XML includes
2429 * @data: application data that will be passed to the parser context 2472 * @data: application data that will be passed to the parser context
2430 * in the _private field of the parser context(s) 2473 * in the _private field of the parser context(s)
2431 * 2474 *
2432 * Implement the XInclude substitution on the XML document @doc 2475 * Implement the XInclude substitution on the XML document @doc
2433 * 2476 *
2434 * Returns 0 if no substitution were done, -1 if some processing failed 2477 * Returns 0 if no substitution were done, -1 if some processing failed
2435 * or the number of substitutions done. 2478 * or the number of substitutions done.
2436 */ 2479 */
2437 int 2480 int
2438 xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) { 2481 xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) {
2439 xmlXIncludeCtxtPtr ctxt;
2440 xmlNodePtr tree; 2482 xmlNodePtr tree;
2441 int ret = 0;
2442 2483
2443 if (doc == NULL) 2484 if (doc == NULL)
2444 return(-1); 2485 return(-1);
2445 tree = xmlDocGetRootElement(doc); 2486 tree = xmlDocGetRootElement(doc);
2446 if (tree == NULL) 2487 if (tree == NULL)
2447 return(-1); 2488 return(-1);
2448 ctxt = xmlXIncludeNewContext(doc); 2489 return(xmlXIncludeProcessTreeFlagsData(tree, flags, data));
2449 if (ctxt == NULL)
2450 » return(-1);
2451 ctxt->_private = data;
2452 ctxt->base = xmlStrdup((xmlChar *)doc->URL);
2453 xmlXIncludeSetFlags(ctxt, flags);
2454 ret = xmlXIncludeDoProcess(ctxt, doc, tree);
2455 if ((ret >= 0) && (ctxt->nbErrors > 0))
2456 » ret = -1;
2457
2458 xmlXIncludeFreeContext(ctxt);
2459 return(ret);
2460 } 2490 }
2461 2491
2462 /** 2492 /**
2463 * xmlXIncludeProcessFlags: 2493 * xmlXIncludeProcessFlags:
2464 * @doc: an XML document 2494 * @doc: an XML document
2465 * @flags: a set of xmlParserOption used for parsing XML includes 2495 * @flags: a set of xmlParserOption used for parsing XML includes
2466 * 2496 *
2467 * Implement the XInclude substitution on the XML document @doc 2497 * Implement the XInclude substitution on the XML document @doc
2468 * 2498 *
2469 * Returns 0 if no substitution were done, -1 if some processing failed 2499 * Returns 0 if no substitution were done, -1 if some processing failed
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 ret = xmlXIncludeDoProcess(ctxt, node->doc, node); 2582 ret = xmlXIncludeDoProcess(ctxt, node->doc, node);
2553 if ((ret >= 0) && (ctxt->nbErrors > 0)) 2583 if ((ret >= 0) && (ctxt->nbErrors > 0))
2554 ret = -1; 2584 ret = -1;
2555 return(ret); 2585 return(ret);
2556 } 2586 }
2557 2587
2558 #else /* !LIBXML_XINCLUDE_ENABLED */ 2588 #else /* !LIBXML_XINCLUDE_ENABLED */
2559 #endif 2589 #endif
2560 #define bottom_xinclude 2590 #define bottom_xinclude
2561 #include "elfgcchack.h" 2591 #include "elfgcchack.h"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698