Commit d076a20e authored by Daniel Veillard's avatar Daniel Veillard

fixed #99082 for xi:include encoding="..." support on text includes. added

* xinclude.c parserInternals.c encoding.c: fixed #99082
  for xi:include encoding="..." support on text includes.
* result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml
  test/XInclude/ents/isolatin.txt : added a specific regression test
* python/generator.py python/libxml2class.txt: fixed the generator
  the new set of comments generated for doc/libxml2-api.xml were
  breaking the python generation.
Daniel
parent 817e70b6
Wed Nov 20 14:24:56 CET 2002 Daniel Veillard <daniel@veillard.com>
* xinclude.c parserInternals.c encoding.c: fixed #99082
for xi:include encoding="..." support on text includes.
* result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml
test/XInclude/ents/isolatin.txt : added a specific regression test
* python/generator.py python/libxml2class.txt: fixed the generator
the new set of comments generated for doc/libxml2-api.xml were
breaking the python generation.
Tue Nov 19 23:25:47 CET 2002 Daniel Veillard <daniel@veillard.com>
* doc/Makefile.am: repair some problem if gtk-doc fail or such
......
......@@ -2120,7 +2120,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
*/
if (ret == -3)
ret = 0;
return (ret);
return (written);
}
/**
......
......@@ -1436,9 +1436,11 @@ xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
ctxt->sax->error(ctxt->userData,
"Char 0x%X out of allowed range\n",
val);
ctxt->errNo = XML_ERR_INVALID_ENCODING;
ctxt->wellFormed = 0;
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
if (ctxt != NULL) {
ctxt->errNo = XML_ERR_INVALID_ENCODING;
ctxt->wellFormed = 0;
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
}
}
return (val);
} else {
......
......@@ -746,7 +746,7 @@ def writeDoc(name, args, indent, output):
output.write('\n ');
output.write(indent)
output.write(val);
output.write('"""\n')
output.write(' """\n')
def buildWrappers():
global ctypes
......
......@@ -150,6 +150,13 @@ validateNamesValue()
validateNmtokenValue()
validateNmtokensValue()
# functions from module wincecompat
close()
getenv()
read()
strerror()
write()
# functions from module xmlIO
checkFilename()
cleanupInputCallbacks()
......@@ -302,7 +309,7 @@ uCSIsUnifiedCanadianAboriginalSyllabics()
uCSIsYiRadicals()
uCSIsYiSyllables()
# functions from module xmlversion
# functions from module xmlwin32version
checkVersion()
# functions from module xpathInternals
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
<!-- Simple test of including another text document -->
test with accents in ISO-8859-1:
</x>
<?xml version="1.0" encoding="ISO-8859-1"?>
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
<!-- Simple test of including another text document -->
<xinclude:include href="../ents/isolatin.txt" encoding="ISO-8859-1" parse="text"/>
</x>
test with accents in ISO-8859-1:
......@@ -25,6 +25,7 @@
#include <libxml/xpointer.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/encoding.h>
#include <libxml/globals.h>
#ifdef LIBXML_XINCLUDE_ENABLED
......@@ -37,6 +38,7 @@
#define XINCLUDE_PARSE (const xmlChar *) "parse"
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
/* #define DEBUG_XINCLUDE */
#ifdef DEBUG_XINCLUDE
......@@ -1106,6 +1108,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlURIPtr uri;
xmlChar *URL;
int i;
xmlChar *encoding = NULL;
xmlCharEncoding enc = 0;
/*
* Check the URL and remove any fragment identifier
*/
......@@ -1150,11 +1155,34 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
goto loaded;
}
}
/*
* Try to get the encoding if available
*/
if ((ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->ref != NULL)) {
encoding = xmlGetProp(ctxt->incTab[nr]->ref, XINCLUDE_PARSE_ENCODING);
}
if (encoding != NULL) {
/*
* TODO: we should not have to remap to the xmlCharEncoding
* predefined set, a better interface than
* xmlParserInputBufferCreateFilename should allow any
* encoding supported by iconv
*/
enc = xmlParseCharEncoding((const char *) encoding);
if (enc == XML_CHAR_ENCODING_ERROR) {
xmlGenericError(xmlGenericErrorContext,
"XInclude: encoding %s not supported\n", encoding);
xmlFree(encoding);
xmlFree(URL);
return(-1);
}
xmlFree(encoding);
}
/*
* Load it.
* Issue 62: how to detect the encoding
*/
buf = xmlParserInputBufferCreateFilename((const char *)URL, 0);
buf = xmlParserInputBufferCreateFilename((const char *)URL, enc);
if (buf == NULL) {
xmlFree(URL);
return(-1);
......@@ -1170,16 +1198,18 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
content = xmlBufferContent(buf->buffer);
len = xmlBufferLength(buf->buffer);
for (i = 0;i < len; i++) {
/*
* TODO: if the encoding issue is solved, scan UTF8 chars instead
*/
if (!IS_CHAR(content[i])) {
for (i = 0;i < len;) {
int cur;
int l;
cur = xmlStringCurrentChar(NULL, &content[i], &l);
if (!IS_CHAR(cur)) {
xmlGenericError(xmlGenericErrorContext,
"XInclude: %s contains invalid char %d\n", URL, content[i]);
"XInclude: %s contains invalid char %d\n", URL, cur);
} else {
xmlNodeAddContentLen(node, &content[i], 1);
xmlNodeAddContentLen(node, &content[i], l);
}
i += l;
}
xmlBufferShrink(buf->buffer, len);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment