+Wed Jun 30 12:28:34 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+ * libxslt/namespaces: some enhancement for fixing bug 142768
+ * tests/namespaces/Makefile.am, tests/namespaces/tst6*:
+ added regression test for this bug
+
Tue Jun 29 09:23:03 CEST 2004 Daniel Veillard <daniel@veillard.com>
* Makefile.am examples/xsltICUSort.c: seems I never commited to CVS
if (URI == NULL)
URI = ns->href;
+ /*
+ * If the parent is an XML_ELEMENT_NODE, and has the "equivalent"
+ * namespace as ns (either both default, or both with a prefix
+ * with the same href) then return the parent's ns record
+ */
if ((out->parent != NULL) &&
(out->parent->type == XML_ELEMENT_NODE) &&
(out->parent->ns != NULL) &&
+ (((out->parent->ns->prefix == NULL) && (ns->prefix == NULL)) ||
+ ((out->parent->ns->prefix != NULL) && (ns->prefix != NULL))) &&
(xmlStrEqual(out->parent->ns->href, URI)))
ret = out->parent->ns;
else {
- if (ns->prefix != NULL) {
- ret = xmlSearchNs(out->doc, out, ns->prefix);
- if ((ret == NULL) || (!xmlStrEqual(ret->href, URI))) {
- ret = xmlSearchNsByHref(out->doc, out, URI);
- }
- } else {
+ /*
+ * do a standard namespace search for ns in the output doc
+ */
+ ret = xmlSearchNs(out->doc, out, ns->prefix);
+ /*
+ * if the search fails and it's not for the default prefix
+ * do a search by href
+ */
+ if ((ret == NULL) && (ns->prefix != NULL))
ret = xmlSearchNsByHref(out->doc, out, URI);
}
- }
- if (ret == NULL) {
+ if (ret == NULL) { /* if no success and an element node, create the ns */
if (out->type == XML_ELEMENT_NODE)
ret = xmlNewNs(out, URI, ns->prefix);
}
tst.xml tst.xsl tst.out \
tst2.xml tst2.xsl tst2.out \
tst3.xml tst3.xsl tst3.out \
- tst4.xml tst4.xsl tst4.out
+ tst4.xml tst4.xsl tst4.out \
# tst5.xml tst5.xsl tst5.out
+ tst6.xml tst6.xsl tst6.out
all:
--- /dev/null
+<?xml version="1.0"?>
+<foo xmlns="urn:foo" xmlns:foo="urn:foo" xmlns:foo2="urn:foo2">
+ <bar>hello</bar>
+ <foo:baz>phaw</foo:baz>
+ <foo:bling xmlns="urn:foo2">
+ <bar2>hello2</bar2>
+ </foo:bling>
+ <bar>hello</bar>
+ <foo:baz>phaw</foo:baz>
+ <bling xmlns="urn:foo2">
+ <bar2>hello2</bar2>
+ </bling>
+</foo>
--- /dev/null
+<foo xmlns="urn:foo" xmlns:foo="urn:foo" xmlns:foo2="urn:foo2">
+ <bar>hello</bar>
+ <foo:baz>phaw</foo:baz>
+ <foo:bling xmlns="urn:foo2">
+ <bar2>hello2</bar2>
+ </foo:bling>
+ <bar>hello</bar>
+ <foo:baz>phaw</foo:baz>
+ <bling xmlns="urn:foo2">
+ <bar2>hello2</bar2>
+ </bling>
+</foo>