1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2026-01-07 21:58:22 +03:00

Fix regression: Default namespace not correctly used

https://bugzilla.gnome.org/show_bug.cgi?id=684564
This commit is contained in:
Nick Wellnhofer
2012-09-28 21:04:39 +02:00
committed by Daniel Veillard
parent 3d7ba80754
commit be264bd303
6 changed files with 44 additions and 6 deletions

View File

@@ -4075,7 +4075,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else if (xmlStrEqual(prefix, BAD_CAST "xml")) {
prefix = NULL;
}
} else if (prefix != NULL) {
} else {
xmlNsPtr ns;
/*
* SPEC XSLT 1.0:
@@ -4090,11 +4090,13 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
* TODO: Check this in the compilation layer in case it's a
* static value.
*/
xsltTransformError(ctxt, NULL, inst,
"xsl:element: The QName '%s:%s' has no "
"namespace binding in scope in the stylesheet; "
"this is an error, since the namespace was not "
"specified by the instruction itself.\n", prefix, name);
if (prefix != NULL) {
xsltTransformError(ctxt, NULL, inst,
"xsl:element: The QName '%s:%s' has no "
"namespace binding in scope in the stylesheet; "
"this is an error, since the namespace was not "
"specified by the instruction itself.\n", prefix, name);
}
} else
nsName = ns->href;
}

View File

@@ -168,6 +168,7 @@ EXTRA_DIST = \
bug-167.xml \
bug-168.xml \
bug-169.xml \
bug-179.xml \
character.xml \
array.xml \
items.xml

1
tests/docs/bug-179.xml Normal file
View File

@@ -0,0 +1 @@
<doc/>

View File

@@ -186,6 +186,7 @@ EXTRA_DIST = \
bug-176.out bug-176.xsl \
bug-177.out bug-177.xsl \
bug-178.out bug-178.xsl \
bug-179.out bug-179.xsl \
character.out character.xsl \
character2.out character2.xsl \
itemschoose.out itemschoose.xsl \

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<root xmlns="my::namespace">
<foo>...</foo>
<bar>...</bar>
<foobar>...</foobar>
<baz>...</baz>
<doc>...</doc>
<baz>...</baz>
</root>

24
tests/general/bug-179.xsl Normal file
View File

@@ -0,0 +1,24 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="my::namespace">
<xsl:variable name="var">baz</xsl:variable>
<xsl:output indent="yes"/>
<xsl:template match="/">
<root> <!-- This is in the correct namespace "my::namespace" -->
<foo>...</foo> <!-- OK. -->
<xsl:element name="bar">...</xsl:element> <!-- Still okay. -->
<!-- Wrong! These are without namespace. -->
<xsl:element name="{concat('foo', 'bar')}">...</xsl:element>
<xsl:element name="{$var}">...</xsl:element>
<xsl:element name="{local-name(*)}">...</xsl:element>
<!-- Explicitly setting the namespace fixes this. -->
<xsl:element name="{$var}" namespace="my::namespace">...</xsl:element>
</root>
</xsl:template>
</xsl:stylesheet>