From 6f46f6c5b8b01441e006428b642c4bb5f528bcbe Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 1 Aug 2002 12:22:24 +0000 Subject: [PATCH] Opening the interface xmlNewCharEncodingHandler as requested in #89415 * encoding.c include/libxml/encoding.h: Opening the interface xmlNewCharEncodingHandler as requested in #89415 * python/generator.py python/setup.py.in: applied cleanup patches from Marc-Andre Lemburg * tree.c: fixing bug #89332 on a specific case of loosing the XML-1.0 namespace on xml:xxx attributes Daniel --- ChangeLog | 9 +++++++++ encoding.c | 3 ++- include/libxml/encoding.h | 5 ++++- python/generator.py | 40 +++++++++++++++++++-------------------- python/setup.py.in | 1 - tree.c | 28 +++++++++++++++++++++++++-- 6 files changed, 61 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95fa321e..3da13049 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Aug 1 12:17:30 CEST 2002 Daniel Veillard + + * encoding.c include/libxml/encoding.h: Opening the interface + xmlNewCharEncodingHandler as requested in #89415 + * python/generator.py python/setup.py.in: applied cleanup + patches from Marc-Andre Lemburg + * tree.c: fixing bug #89332 on a specific case of loosing + the XML-1.0 namespace on xml:xxx attributes + Wed Jul 31 23:27:42 2002 Aleksey Sanin * c14n.c include/libxml/c14n.h: fixed one more c14n + namespaces diff --git a/encoding.c b/encoding.c index d2d5ca23..69b3dacc 100644 --- a/encoding.c +++ b/encoding.c @@ -1481,9 +1481,10 @@ static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL; * @output: the xmlCharEncodingOutputFunc to write that encoding * * Create and registers an xmlCharEncodingHandler. + * * Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error). */ -static xmlCharEncodingHandlerPtr +xmlCharEncodingHandlerPtr xmlNewCharEncodingHandler(const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output) { diff --git a/include/libxml/encoding.h b/include/libxml/encoding.h index a1946c22..27bdd1be 100644 --- a/include/libxml/encoding.h +++ b/include/libxml/encoding.h @@ -155,7 +155,10 @@ xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler (xmlCharEncoding enc); xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler (const char *name); - +xmlCharEncodingHandlerPtr + xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); /* * Interfaces for encoding names and aliases. diff --git a/python/generator.py b/python/generator.py index 863e2b1c..5533f346 100755 --- a/python/generator.py +++ b/python/generator.py @@ -74,7 +74,7 @@ class SlowParser(xmllib.XMLParser): def getparser(target = None): # get the fastest available parser, and attach it to an # unmarshalling object. return both objects. - if target == None: + if target is None: target = docParser() if FastParser: return FastParser(target), target @@ -392,7 +392,7 @@ def print_function_wrapper(name, output, export, include): if file == "python": # Those have been manually generated return 1 - if file == "python_accessor" and ret[0] != "void" and ret[2] == None: + if file == "python_accessor" and ret[0] != "void" and ret[2] is None: # Those have been manually generated return 1 @@ -651,7 +651,7 @@ def functionCompare(info1, info2): return 0 def writeDoc(name, args, indent, output): - if functions[name][0] == None or functions[name][0] == "": + if functions[name][0] is None or functions[name][0] == "": return val = functions[name][0] val = string.replace(val, "NULL", "None"); @@ -789,7 +789,7 @@ def buildWrappers(): for arg in args: if classes_type.has_key(arg[1]): - classes.write(" if %s == None: %s__o = None\n" % + classes.write(" if %s is None: %s__o = None\n" % (arg[0], arg[0])) classes.write(" else: %s__o = %s%s\n" % (arg[0], arg[0], classes_type[arg[1]][0])) @@ -813,22 +813,22 @@ def buildWrappers(): # Raise an exception # if functions_noexcept.has_key(name): - classes.write(" if ret == None:return None\n"); + classes.write(" if ret is None:return None\n"); elif string.find(name, "URI") >= 0: classes.write( - " if ret == None:raise uriError('%s() failed')\n" + " if ret is None:raise uriError('%s() failed')\n" % (name)) elif string.find(name, "XPath") >= 0: classes.write( - " if ret == None:raise xpathError('%s() failed')\n" + " if ret is None:raise xpathError('%s() failed')\n" % (name)) elif string.find(name, "Parse") >= 0: classes.write( - " if ret == None:raise parserError('%s() failed')\n" + " if ret is None:raise parserError('%s() failed')\n" % (name)) else: classes.write( - " if ret == None:raise treeError('%s() failed')\n" + " if ret is None:raise treeError('%s() failed')\n" % (name)) classes.write(" return "); classes.write(classes_type[ret[0]][1] % ("ret")); @@ -898,7 +898,7 @@ def buildWrappers(): for arg in args: if classes_type.has_key(arg[1]): if n != index: - classes.write(" if %s == None: %s__o = None\n" % + classes.write(" if %s is None: %s__o = None\n" % (arg[0], arg[0])) classes.write(" else: %s__o = %s%s\n" % (arg[0], arg[0], classes_type[arg[1]][0])) @@ -929,22 +929,22 @@ def buildWrappers(): # if functions_noexcept.has_key(name): classes.write( - " if ret == None:return None\n"); + " if ret is None:return None\n"); elif string.find(name, "URI") >= 0: classes.write( - " if ret == None:raise uriError('%s() failed')\n" + " if ret is None:raise uriError('%s() failed')\n" % (name)) elif string.find(name, "XPath") >= 0: classes.write( - " if ret == None:raise xpathError('%s() failed')\n" + " if ret is None:raise xpathError('%s() failed')\n" % (name)) elif string.find(name, "Parse") >= 0: classes.write( - " if ret == None:raise parserError('%s() failed')\n" + " if ret is None:raise parserError('%s() failed')\n" % (name)) else: classes.write( - " if ret == None:raise treeError('%s() failed')\n" + " if ret is None:raise treeError('%s() failed')\n" % (name)) classes.write(" return "); classes.write(classes_type[ret[0]][1] % ("ret")); @@ -955,22 +955,22 @@ def buildWrappers(): # if functions_noexcept.has_key(name): classes.write( - " if ret == None:return None"); + " if ret is None:return None"); elif string.find(name, "URI") >= 0: classes.write( - " if ret == None:raise uriError('%s() failed')\n" + " if ret is None:raise uriError('%s() failed')\n" % (name)) elif string.find(name, "XPath") >= 0: classes.write( - " if ret == None:raise xpathError('%s() failed')\n" + " if ret is None:raise xpathError('%s() failed')\n" % (name)) elif string.find(name, "Parse") >= 0: classes.write( - " if ret == None:raise parserError('%s() failed')\n" + " if ret is None:raise parserError('%s() failed')\n" % (name)) else: classes.write( - " if ret == None:raise treeError('%s() failed')\n" + " if ret is None:raise treeError('%s() failed')\n" % (name)) classes.write(" return "); classes.write(converter_type[ret[0]] % ("ret")); diff --git a/python/setup.py.in b/python/setup.py.in index 69a84180..109b8983 100755 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -127,7 +127,6 @@ if with_xslt == 1: libraries=libs)) if missing("MANIFEST"): - global xml_files manifest = open("MANIFEST", "w") manifest.write("setup.py\n") diff --git a/tree.c b/tree.c index f958cb20..d879e546 100644 --- a/tree.c +++ b/tree.c @@ -4438,8 +4438,26 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) { if (node == NULL) return(NULL); if ((nameSpace != NULL) && (xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) { - if (doc == NULL) - return(NULL); + if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) { + /* + * The XML-1.0 namespace is normally held on the root + * element. In this case exceptionally create it on the + * node element. + */ + cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs)); + if (cur == NULL) { + xmlGenericError(xmlGenericErrorContext, + "xmlSearchNs : malloc failed\n"); + return(NULL); + } + memset(cur, 0, sizeof(xmlNs)); + cur->type = XML_LOCAL_NAMESPACE; + cur->href = xmlStrdup(XML_XML_NAMESPACE); + cur->prefix = xmlStrdup((const xmlChar *)"xml"); + cur->next = node->nsDef; + node->nsDef = cur; + return(cur); + } if (doc->oldNs == NULL) { /* * Allocate a new Namespace and fill the fields. @@ -5863,6 +5881,9 @@ xmlNsDump(xmlBufferPtr buf, xmlNsPtr cur) { return; } if (cur->type == XML_LOCAL_NAMESPACE) { + if (xmlStrEqual(cur->prefix, BAD_CAST "xml")) + return; + /* Within the context of an element attributes */ if (cur->prefix != NULL) { xmlBufferWriteChar(buf, " xmlns:"); @@ -6395,6 +6416,9 @@ xmlNsDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur) { return; } if ((cur->type == XML_LOCAL_NAMESPACE) && (cur->href != NULL)) { + if (xmlStrEqual(cur->prefix, BAD_CAST "xml")) + return; + /* Within the context of an element attributes */ if (cur->prefix != NULL) { xmlOutputBufferWriteString(buf, " xmlns:");