diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2003-02-04 21:12:33 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2003-02-04 21:12:33 +0000 |
commit | 745ee1b06d820eba7fc4e0a0c22e32fbf752a7f9 (patch) | |
tree | b302cfcf1a9c33af59def846019836098295777d | |
parent | aac5d52c7d2aef88f96c39b06bb0d9ac3baebd3f (diff) | |
download | libxslt-745ee1b06d820eba7fc4e0a0c22e32fbf752a7f9.tar.gz libxslt-745ee1b06d820eba7fc4e0a0c22e32fbf752a7f9.tar.bz2 libxslt-745ee1b06d820eba7fc4e0a0c22e32fbf752a7f9.zip |
fixing bug #105116 sometimes one need to generate a default namespace
* libxslt/transform.c: fixing bug #105116 sometimes one need
to generate a default namespace reset xmlns="" in the output
* tests/docs/Makefile.am tests/docs/bug-103.xml
tests/general/Makefile.am tests/general/bug-103*: added the
example in the regression tests for this case
Daniel
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | libxslt/transform.c | 30 | ||||
-rw-r--r-- | tests/docs/Makefile.am | 1 | ||||
-rw-r--r-- | tests/docs/bug-103.xml | 1 | ||||
-rw-r--r-- | tests/general/Makefile.am | 1 | ||||
-rw-r--r-- | tests/general/bug-103.out | 2 | ||||
-rw-r--r-- | tests/general/bug-103.xsl | 13 |
7 files changed, 50 insertions, 6 deletions
@@ -1,3 +1,11 @@ +Tue Feb 4 22:10:17 CET 2003 Daniel Veillard <daniel@veillard.com> + + * libxslt/transform.c: fixing bug #105116 sometimes one need + to generate a default namespace reset xmlns="" in the output + * tests/docs/Makefile.am tests/docs/bug-103.xml + tests/general/Makefile.am tests/general/bug-103*: added the + example in the regression tests for this case + Tue Feb 4 18:39:35 CET 2003 Daniel Veillard <daniel@veillard.com> * libxslt/pattern.c libxslt/transform.c: changed the way the diff --git a/libxslt/transform.c b/libxslt/transform.c index 851bb77e..5c4b33f4 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -713,10 +713,18 @@ xsltCopyNode(xsltTransformContextPtr ctxt, xmlNodePtr node, if (node->nsDef != NULL) xsltCopyNamespaceList(ctxt, copy, node->nsDef); } - if (((node->type == XML_ELEMENT_NODE) || - (node->type == XML_ATTRIBUTE_NODE)) && - (node->ns != NULL)) { - copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy); + if ((node->type == XML_ELEMENT_NODE) || + (node->type == XML_ATTRIBUTE_NODE)) { + if (node->ns != NULL) + copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy); + else if ((insert != NULL) && (insert->type == XML_ELEMENT_NODE) && + (insert->ns != NULL)) { + xmlNsPtr defaultNs; + + defaultNs = xmlSearchNs(insert->doc, insert, NULL); + if (defaultNs != NULL) + xmlNewNs(copy, BAD_CAST "", NULL); + } } } else { xsltTransformError(ctxt, NULL, node, @@ -827,8 +835,18 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node, /* * Add namespaces as they are needed */ - if (node->ns != NULL) { - copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy); + if ((node->type == XML_ELEMENT_NODE) || + (node->type == XML_ATTRIBUTE_NODE)) { + if (node->ns != NULL) + copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy); + else if ((insert != NULL) && (insert->type == XML_ELEMENT_NODE) && + (insert->ns != NULL)) { + xmlNsPtr defaultNs; + + defaultNs = xmlSearchNs(insert->doc, insert, NULL); + if (defaultNs != NULL) + xmlNewNs(copy, BAD_CAST "", NULL); + } } if (node->nsDef != NULL) xsltCopyNamespaceList(ctxt, copy, node->nsDef); diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am index 97e4bc28..4150027e 100644 --- a/tests/docs/Makefile.am +++ b/tests/docs/Makefile.am @@ -102,6 +102,7 @@ EXTRA_DIST = \ bug-100.xml \ bug-101.xml \ bug-102.xml \ + bug-103.xml \ character.xml \ array.xml \ items.xml diff --git a/tests/docs/bug-103.xml b/tests/docs/bug-103.xml new file mode 100644 index 00000000..f1999f80 --- /dev/null +++ b/tests/docs/bug-103.xml @@ -0,0 +1 @@ +<foo/> diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index 255c027e..449a70f5 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -107,6 +107,7 @@ EXTRA_DIST = \ bug-101.out bug-101.xsl \ bug-102.out bug-102.xsl \ bug-102-inc.out bug-102-inc.xsl \ + bug-103.out bug-103.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-103.out b/tests/general/bug-103.out new file mode 100644 index 00000000..7e1623c7 --- /dev/null +++ b/tests/general/bug-103.out @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<report xmlns="http://examplotron.org/namespaces/example"><foo xmlns=""/></report> diff --git a/tests/general/bug-103.xsl b/tests/general/bug-103.xsl new file mode 100644 index 00000000..efa0f801 --- /dev/null +++ b/tests/general/bug-103.xsl @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + > + + <xsl:template match="/"> + <report xmlns="http://examplotron.org/namespaces/example"> + <xsl:copy-of select="foo"/> + </report> + </xsl:template> + +</xsl:stylesheet> + |