From d9f254b22aa1788e296d8e4d7d8f9f68574f079b Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Thu, 1 Jul 2004 02:25:08 +0000 Subject: [PATCH] added coding to xsltCopyTree to copy namespaces (bug 139578). changed to * libxslt/transform.c: added coding to xsltCopyTree to copy namespaces (bug 139578). * tests/general/bug-128.out: changed to reflect above fix * libxslt/xslt.c: minor change to an error message --- ChangeLog | 7 +++++++ libxslt/transform.c | 18 ++++++++++++++++-- libxslt/xslt.c | 4 ++-- tests/general/bug-128.out | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 995535a..ab235c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Jul 1 10:07:55 HKT 2004 William Brack + + * libxslt/transform.c: added coding to xsltCopyTree to copy + namespaces (bug 139578). + * tests/general/bug-128.out: changed to reflect above fix + * libxslt/xslt.c: minor change to an error message + Wed Jun 30 18:41:20 CEST 2004 Daniel Veillard * win32/Makefile.msvc win32/Makefile.mingw libexslt/Makefile.am diff --git a/libxslt/transform.c b/libxslt/transform.c index 3a70da5..25c362c 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -1010,16 +1010,30 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node, */ if ((node->type == XML_ELEMENT_NODE) || (node->type == XML_ATTRIBUTE_NODE)) { + xmlNsPtr *nsList, *cur, ns; if (node->ns != NULL) copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy); - else if ((insert != NULL) && (insert->type == XML_ELEMENT_NODE) && - (insert->ns != NULL)) { + else if ((insert->type == XML_ELEMENT_NODE) && (insert->ns != NULL)) { xmlNsPtr defaultNs; defaultNs = xmlSearchNs(insert->doc, insert, NULL); if (defaultNs != NULL) xmlNewNs(copy, BAD_CAST "", NULL); } + /* + * must also add in any new namespaces in scope for the node + */ + nsList = xmlGetNsList(node->doc, node); + if (nsList != NULL) { + cur = nsList; + while (*cur != NULL) { + ns = xmlSearchNsByHref(insert->doc, insert, (*cur)->href); + if (ns == NULL) + xmlNewNs(copy, (*cur)->href, (*cur)->prefix); + cur++; + } + xmlFree(nsList); + } } if (node->nsDef != NULL) { if (literal) diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 85937bb..2445c76 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -585,7 +585,7 @@ xsltGetInheritedNsList(xsltStylesheetPtr style, sizeof(xmlNsPtr)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, - "xmlGetNsList : out of memory!\n"); + "xsltGetInheritedNsList : out of memory!\n"); return(0); } ret[nbns] = NULL; @@ -604,7 +604,7 @@ xsltGetInheritedNsList(xsltStylesheetPtr style, sizeof(xmlNsPtr)); if (ret == NULL) { xmlGenericError(xmlGenericErrorContext, - "xmlGetNsList : realloc failed!\n"); + "xsltGetInheritedNsList : realloc failed!\n"); return(0); } } diff --git a/tests/general/bug-128.out b/tests/general/bug-128.out index 31a5e2e..fcd73db 100644 --- a/tests/general/bug-128.out +++ b/tests/general/bug-128.out @@ -1,5 +1,5 @@ - - + + -- 2.7.4