From 8f56a0b269b2a938612f33e06e049745c7e3b96a Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 5 Dec 2002 17:07:18 +0000 Subject: [PATCH] xsl:element generated superfluous xmlns declarations, closes bug #99905 * libxslt/transform.c: xsl:element generated superfluous xmlns declarations, closes bug #99905 * tests/docs/Makefile.am tests/docs/bug-101.xml tests/general/Makefile.am tests/general/bug-101.*: added the example in the regression tests for this case Daniel --- ChangeLog | 8 ++++++++ libxslt/transform.c | 12 ++++++++++-- tests/docs/Makefile.am | 1 + tests/docs/bug-101.xml | 1 + tests/general/Makefile.am | 1 + tests/general/bug-101.out | 2 ++ tests/general/bug-101.xsl | 8 ++++++++ 7 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/docs/bug-101.xml create mode 100644 tests/general/bug-101.out create mode 100644 tests/general/bug-101.xsl diff --git a/ChangeLog b/ChangeLog index b05a3a3..c0970cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 5 18:05:44 CET 2002 Daniel Veillard + + * libxslt/transform.c: xsl:element generated superfluous xmlns + declarations, closes bug #99905 + * tests/docs/Makefile.am tests/docs/bug-101.xml + tests/general/Makefile.am tests/general/bug-101.*: added the + example in the regression tests for this case + Wed Dec 4 18:12:24 CET 2002 Daniel Veillard * libxslt/xslt.c: Matt Sergeant reported a bug when having comments diff --git a/libxslt/transform.c b/libxslt/transform.c index 73d3e05..183746e 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -2242,8 +2242,16 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node, goto error; } if (generateDefault == 1) { - ns = xmlNewNs(copy, comp->ns, NULL); - copy->ns = ns; + xmlNsPtr defaultNs = NULL; + + if ((ctxt->insert != NULL) && (ctxt->insert->type == XML_ELEMENT_NODE)) + defaultNs = xmlSearchNs(ctxt->insert->doc, ctxt->insert, NULL); + if ((defaultNs == NULL) || (!xmlStrEqual(defaultNs->href, comp->ns))) { + ns = xmlNewNs(copy, comp->ns, NULL); + copy->ns = ns; + } else { + copy->ns = defaultNs; + } } else if ((ns == NULL) && (oldns != NULL)) { /* very specific case xsltGetNamespace failed */ ns = xmlNewNs(copy, oldns->href, oldns->prefix); diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am index 890c134..f6f5793 100644 --- a/tests/docs/Makefile.am +++ b/tests/docs/Makefile.am @@ -100,6 +100,7 @@ EXTRA_DIST = \ bug-98.xml \ bug-99.xml \ bug-100.xml \ + bug-101.xml \ character.xml \ array.xml \ items.xml diff --git a/tests/docs/bug-101.xml b/tests/docs/bug-101.xml new file mode 100644 index 0000000..69d62f2 --- /dev/null +++ b/tests/docs/bug-101.xml @@ -0,0 +1 @@ + diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index 3e2b9e7..3f84445 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -104,6 +104,7 @@ EXTRA_DIST = \ bug-98.out bug-98.xsl \ bug-99.out bug-99.xsl \ bug-100.out bug-100.xsl \ + bug-101.out bug-101.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-101.out b/tests/general/bug-101.out new file mode 100644 index 0000000..42c6578 --- /dev/null +++ b/tests/general/bug-101.out @@ -0,0 +1,2 @@ + + diff --git a/tests/general/bug-101.xsl b/tests/general/bug-101.xsl new file mode 100644 index 0000000..ebfcead --- /dev/null +++ b/tests/general/bug-101.xsl @@ -0,0 +1,8 @@ + + + + + + + + -- 2.7.4