+Mon May 15 22:32:13 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * libxslt/namespaces.c libxslt/attributes.c:
+ Fixed bug #302020, reported by Thomas Blatter.
+
Fri May 12 23:23:06 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* libxslt/documents.c libxslt/namespaces.c
namespace = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)
"namespace", XSLT_NAMESPACE);
- if (namespace != NULL) {
+ /*
+ * This fixes bug #302020: check also for the empty string.
+ */
+ if ((namespace != NULL) && (*namespace != 0)) {
ns = xsltGetSpecialNamespace(ctxt, inst, namespace, prefix,
ctxt->insert);
xmlFree(namespace);
if (attr != NULL)
return;
}
- value = xsltEvalTemplateString(ctxt, node, inst);
+ value = xsltEvalTemplateString(ctxt, node, inst); /* OPTIMIZE TODO: expensive! */
if (value == NULL) {
if (ns) {
attr = xmlSetNsProp(ctxt->insert, ns, name,
return(NULL);
if ((prefix == NULL) && (URI[0] == 0)) {
+ /*
+ * This tries to "undeclare" a default namespace.
+ * This fixes a part of bug #302020:
+ * 1) Added a check whether the queried ns-decl
+ * is already an "undeclaration" of the default
+ * namespace.
+ * 2) This fires an error if the default namespace
+ * couldn't be "undeclared".
+ */
ret = xmlSearchNs(out->doc, out, NULL);
- if (ret != NULL) {
- ret = xmlNewNs(out, URI, prefix);
+ if ((ret == NULL) ||
+ (ret->href == NULL) || (ret->href[0] == 0))
return(ret);
+
+ if (ret != NULL) {
+ xmlNsPtr newns;
+
+ newns = xmlNewNs(out, URI, prefix);
+ if (newns == NULL) {
+ xsltTransformError(ctxt, NULL, cur,
+ "Namespace fixup error: Failed to undeclare "
+ "the default namespace '%s'.\n",
+ ret->href);
+ }
+ /*
+ * TODO: Why does this try to return an xmlns="" at all?
+ */
+ return(newns);
}
return(NULL);
}