Index: xinclude.c =================================================================== RCS file: /cvs/gnome/gnome-xml/xinclude.c,v retrieving revision 1.16 diff -u -r1.16 xinclude.c --- xinclude.c 2001/06/24 12:13:20 1.16 +++ xinclude.c 2001/07/03 01:06:29 @@ -32,6 +32,7 @@ #define XINCLUDE_NODE (const xmlChar *) "include" #define XINCLUDE_HREF (const xmlChar *) "href" #define XINCLUDE_PARSE (const xmlChar *) "parse" +#define XINCLUDE_ENCODING (const xmlChar *) "encoding" #define XINCLUDE_PARSE_XML (const xmlChar *) "xml" #define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" @@ -546,7 +547,8 @@ * Load the content, and store the result in the XInclude context */ static void -xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { +xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, + int nr, xmlCharEncoding encoding) { xmlParserInputBufferPtr buf; xmlNodePtr node; xmlURIPtr uri; @@ -598,9 +600,8 @@ } /* * Load it. - * Issue 62: how to detect the encoding */ - buf = xmlParserInputBufferCreateFilename((const char *)URL, 0); + buf = xmlParserInputBufferCreateFilename((const char *)URL, encoding); if (buf == NULL) { xmlGenericError(xmlGenericErrorContext, "XInclude: could not load %s\n", URL); @@ -680,6 +681,7 @@ xmlChar *parse; xmlChar *base; xmlChar *URI; + xmlCharEncoding encoding = 0; int xml = 1; /* default Issue 64 */ if (ctxt == NULL) @@ -711,9 +713,32 @@ if (parse != NULL) { if (xmlStrEqual(parse, XINCLUDE_PARSE_XML)) xml = 1; - else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT)) + else if (xmlStrEqual(parse, XINCLUDE_PARSE_TEXT)) { + xmlChar *enc; + xml = 0; - else { + enc = xmlGetProp (cur, XINCLUDE_ENCODING); + if (enc != NULL) { + encoding = xmlParseCharEncoding ((const char*) enc); + if (encoding == XML_CHAR_ENCODING_ERROR) { + xmlGenericError(xmlGenericErrorContext, + "XInclude: invalid value %s for %s\n", + enc, XINCLUDE_ENCODING); + xmlFree(enc); + if (href != NULL) + xmlFree(href); + if (parse != NULL) + xmlFree(parse); + return(-1); + } +#ifdef DEBUG_XINCLUDE + xmlGenericError(xmlGenericErrorContext, + "XInclude: encoding %s (%d)\n", + enc, encoding); +#endif + xmlFree(enc); + } + } else { xmlGenericError(xmlGenericErrorContext, "XInclude: invalid value %s for %s\n", parse, XINCLUDE_PARSE); @@ -771,7 +796,7 @@ xmlXIncludeLoadDoc(ctxt, URI, nr); /* xmlXIncludeGetFragment(ctxt, cur, URI); */ } else { - xmlXIncludeLoadTxt(ctxt, URI, nr); + xmlXIncludeLoadTxt(ctxt, URI, nr, encoding); } /*