| 1 | From be264bd3034b352a7c768ba62bf62cca22d074d9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nick Wellnhofer <wellnhofer@aevum.de> |
| 3 | Date: Fri, 28 Sep 2012 19:04:39 +0000 |
| 4 | Subject: Fix regression: Default namespace not correctly used |
| 5 | |
| 6 | https://bugzilla.gnome.org/show_bug.cgi?id=684564 |
| 7 | --- |
| 8 | diff --git a/libxslt/transform.c b/libxslt/transform.c |
| 9 | index de2ef3c..35701de 100644 |
| 10 | --- a/libxslt/transform.c |
| 11 | +++ b/libxslt/transform.c |
| 12 | @@ -4075,7 +4075,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node, |
| 13 | } else if (xmlStrEqual(prefix, BAD_CAST "xml")) { |
| 14 | prefix = NULL; |
| 15 | } |
| 16 | - } else if (prefix != NULL) { |
| 17 | + } else { |
| 18 | xmlNsPtr ns; |
| 19 | /* |
| 20 | * SPEC XSLT 1.0: |
| 21 | @@ -4090,11 +4090,13 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node, |
| 22 | * TODO: Check this in the compilation layer in case it's a |
| 23 | * static value. |
| 24 | */ |
| 25 | - xsltTransformError(ctxt, NULL, inst, |
| 26 | - "xsl:element: The QName '%s:%s' has no " |
| 27 | - "namespace binding in scope in the stylesheet; " |
| 28 | - "this is an error, since the namespace was not " |
| 29 | - "specified by the instruction itself.\n", prefix, name); |
| 30 | + if (prefix != NULL) { |
| 31 | + xsltTransformError(ctxt, NULL, inst, |
| 32 | + "xsl:element: The QName '%s:%s' has no " |
| 33 | + "namespace binding in scope in the stylesheet; " |
| 34 | + "this is an error, since the namespace was not " |
| 35 | + "specified by the instruction itself.\n", prefix, name); |
| 36 | + } |
| 37 | } else |
| 38 | nsName = ns->href; |
| 39 | } |
| 40 | diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am |
| 41 | index 9e2204f..12a97a8 100644 |
| 42 | --- a/tests/docs/Makefile.am |
| 43 | +++ b/tests/docs/Makefile.am |
| 44 | @@ -168,6 +168,7 @@ EXTRA_DIST = \ |
| 45 | bug-167.xml \ |
| 46 | bug-168.xml \ |
| 47 | bug-169.xml \ |
| 48 | + bug-179.xml \ |
| 49 | character.xml \ |
| 50 | array.xml \ |
| 51 | items.xml |
| 52 | diff --git a/tests/docs/bug-179.xml b/tests/docs/bug-179.xml |
| 53 | new file mode 100644 |
| 54 | index 0000000..69d62f2 |
| 55 | --- a/dev/null |
| 56 | +++ b/tests/docs/bug-179.xml |
| 57 | @@ -0,0 +1 @@ |
| 58 | +<doc/> |
| 59 | diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am |
| 60 | index 364fdd9..762eca9 100644 |
| 61 | --- a/tests/general/Makefile.am |
| 62 | +++ b/tests/general/Makefile.am |
| 63 | @@ -186,6 +186,7 @@ EXTRA_DIST = \ |
| 64 | bug-176.out bug-176.xsl \ |
| 65 | bug-177.out bug-177.xsl \ |
| 66 | bug-178.out bug-178.xsl \ |
| 67 | + bug-179.out bug-179.xsl \ |
| 68 | character.out character.xsl \ |
| 69 | character2.out character2.xsl \ |
| 70 | itemschoose.out itemschoose.xsl \ |
| 71 | diff --git a/tests/general/bug-179.out b/tests/general/bug-179.out |
| 72 | new file mode 100644 |
| 73 | index 0000000..0a7e67d |
| 74 | --- a/dev/null |
| 75 | +++ b/tests/general/bug-179.out |
| 76 | @@ -0,0 +1,9 @@ |
| 77 | +<?xml version="1.0"?> |
| 78 | +<root xmlns="my::namespace"> |
| 79 | + <foo>...</foo> |
| 80 | + <bar>...</bar> |
| 81 | + <foobar>...</foobar> |
| 82 | + <baz>...</baz> |
| 83 | + <doc>...</doc> |
| 84 | + <baz>...</baz> |
| 85 | +</root> |
| 86 | diff --git a/tests/general/bug-179.xsl b/tests/general/bug-179.xsl |
| 87 | new file mode 100644 |
| 88 | index 0000000..5847e9a |
| 89 | --- a/dev/null |
| 90 | +++ b/tests/general/bug-179.xsl |
| 91 | @@ -0,0 +1,24 @@ |
| 92 | +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 93 | + xmlns="my::namespace"> |
| 94 | + |
| 95 | +<xsl:variable name="var">baz</xsl:variable> |
| 96 | + |
| 97 | +<xsl:output indent="yes"/> |
| 98 | + |
| 99 | +<xsl:template match="/"> |
| 100 | + <root> <!-- This is in the correct namespace "my::namespace" --> |
| 101 | + <foo>...</foo> <!-- OK. --> |
| 102 | + <xsl:element name="bar">...</xsl:element> <!-- Still okay. --> |
| 103 | + |
| 104 | + <!-- Wrong! These are without namespace. --> |
| 105 | + <xsl:element name="{concat('foo', 'bar')}">...</xsl:element> |
| 106 | + <xsl:element name="{$var}">...</xsl:element> |
| 107 | + <xsl:element name="{local-name(*)}">...</xsl:element> |
| 108 | + |
| 109 | + <!-- Explicitly setting the namespace fixes this. --> |
| 110 | + <xsl:element name="{$var}" namespace="my::namespace">...</xsl:element> |
| 111 | + </root> |
| 112 | +</xsl:template> |
| 113 | + |
| 114 | +</xsl:stylesheet> |
| 115 | + |
| 116 | -- |
| 117 | cgit v0.9.0.2 |