MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXIncludeLoadTxt

Function xmlXIncludeLoadTxt

ThirdParty/libxml2/vtklibxml2/xinclude.c:1586–1764  ·  view source on GitHub ↗

* xmlXIncludeLoadTxt: * @ctxt: the XInclude context * @ref: an XMLXincludeRefPtr * * Load the content, and store the result in the XInclude context * * Returns 0 in case of success, -1 in case of failure */

Source from the content-addressed store, hash-verified

1584 * Returns 0 in case of success, -1 in case of failure
1585 */
1586static int
1587xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
1588 xmlParserInputBufferPtr buf;
1589 xmlNodePtr node = NULL;
1590 const xmlChar *url = ref->URI;
1591 int i;
1592 int ret = -1;
1593 xmlChar *encoding = NULL;
1594 xmlCharEncodingHandlerPtr handler = NULL;
1595 xmlParserCtxtPtr pctxt = NULL;
1596 xmlParserInputPtr inputStream = NULL;
1597 int len;
1598 int res;
1599 const xmlChar *content;
1600
1601 /*
1602 * Handling of references to the local document are done
1603 * directly through ctxt->doc.
1604 */
1605 if (url[0] == 0) {
1606 xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_TEXT_DOCUMENT,
1607 "text serialization of document not available\n", NULL);
1608 goto error;
1609 }
1610
1611 /*
1612 * Prevent reloading the document twice.
1613 */
1614 for (i = 0; i < ctxt->txtNr; i++) {
1615 if (xmlStrEqual(url, ctxt->txtTab[i].url)) {
1616 node = xmlNewDocText(ctxt->doc, ctxt->txtTab[i].text);
1617 if (node == NULL)
1618 xmlXIncludeErrMemory(ctxt);
1619 goto loaded;
1620 }
1621 }
1622
1623 /*
1624 * Try to get the encoding if available
1625 */
1626 if (ref->elem != NULL) {
1627 encoding = xmlXIncludeGetProp(ctxt, ref->elem, XINCLUDE_PARSE_ENCODING);
1628 }
1629 if (encoding != NULL) {
1630 res = xmlOpenCharEncodingHandler((const char *) encoding,
1631 /* output */ 0, &handler);
1632
1633 if (res != 0) {
1634 if (res == XML_ERR_NO_MEMORY) {
1635 xmlXIncludeErrMemory(ctxt);
1636 } else if (res == XML_ERR_UNSUPPORTED_ENCODING) {
1637 xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_UNKNOWN_ENCODING,
1638 "encoding %s not supported\n", encoding);
1639 goto error;
1640 } else {
1641 xmlXIncludeErr(ctxt, ref->elem, res,
1642 "unexpected error from iconv or ICU\n", NULL);
1643 goto error;

Callers 1

xmlXIncludeLoadNodeFunction · 0.85

Calls 15

xmlStrEqualFunction · 0.85
xmlNewDocTextFunction · 0.85
xmlXIncludeErrMemoryFunction · 0.85
xmlXIncludeGetPropFunction · 0.85
xmlNewParserCtxtFunction · 0.85
xmlCtxtSetErrorHandlerFunction · 0.85
xmlLoadExternalEntityFunction · 0.85
xmlCharEncCloseFuncFunction · 0.85
xmlParserInputBufferReadFunction · 0.85
xmlBufContentFunction · 0.85
xmlBufLengthFunction · 0.85

Tested by

no test coverage detected