After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 313711 - namespace collision with namespace-alias
namespace collision with namespace-alias
Status: RESOLVED OBSOLETE
Product: libxslt
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: kbuchcik
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-08-17 11:19 UTC by Oleg Paraschenko
Modified: 2021-07-05 11:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Oleg Paraschenko 2005-08-17 11:19:52 UTC
I'm trying to write a sort of generative XSLT: an XSLT stylesheet which creates
another XSLT stylesheet. Unfortunately, I've confused xsltproc.

The simplest example if the following. I copy content of "xsl:stylesheet" as is
and add a dummy template.

[code]
<xsl:stylesheet
	xmlns:xsl  = "http://www.w3.org/1999/XSL/Transform"
	xmlns:axsl = "http://www.w3.org/1999/XSL/TransformAlias"
  version    = "1.0">
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

<xsl:template match="xsl:stylesheet">
	<xsl:copy>
		<xsl:copy-of select="node()|@*"/>
		<axsl:template match="none"/>
	</xsl:copy>
</xsl:template>

</xsl:stylesheet>
[/code]

Note that "xsl:copy-of" and "axsl:template" are in different namespaces. Now
apply this stylesheet to itself. Result is the following.

[code]
<?xml version="1.0"?>
<axsl:stylesheet xmlns:axsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<axsl:namespace-alias xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
stylesheet-prefix="axsl" result-prefix="xsl"/>

<axsl:template xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
match="xsl:stylesheet">
	<axsl:copy>
		<axsl:copy-of select="node()|@*"/>
		<axsl:template match="none"/>
	</axsl:copy>
</axsl:template>

<axsl:template match="none"/></axsl:stylesheet>
[/code]

Now "axsl:copy-of" and "axml:template" are in the same namespace. It is incorrect.

By the way:

1) I expected that output prefix should be "xsl", not "axsl" (despite the
specification doesn't require it).

2) Here is output from Saxon:

[code]
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" version="1.0">
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

<xsl:template match="xsl:stylesheet">
	<xsl:copy>
		<xsl:copy-of select="node()|@*"/>
		<axsl:template match="none"/>
	</xsl:copy>
</xsl:template>

<axsl:template xmlns:axsl="http://www.w3.org/1999/XSL/Transform"
match="none"/></xsl:stylesheet>
[/code]
Comment 1 kbuchcik 2006-05-12 10:50:21 UTC
True, the current result is incorrect.

The XSLT 1.0 spec does not define which prefix to use for the resulting
namespace binding. For XSLT 2.0 this is defined: the result-prefix is used,
if in-scope for both the xsl:namespace-alias and the literal result element
(see bug #341325).

The problem is anchored in xsltGetNamespace() (namespaces.c), which
will apply namespace aliases. We get this effect if copying from the
source tree:
xsltCopyTree() --> xsltGetNamespace()
xsltCopyPropList() --> xsltGetNamespace()

Namespace aliases are only intended for literal result elements - not
for source trees. So we need to remove the ns-aliasing in all functions,
which are intended to be used on non literal result elements.
Comment 2 kbuchcik 2006-06-19 15:18:54 UTC
Output of Saxon 8.1.1:
---------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

  <xsl:template match="xsl:stylesheet">
  	<xsl:copy>
  		<xsl:copy-of select="node()|@*"/>
  		<axsl:template match="none"/>
  	</xsl:copy>
  </xsl:template>

<xsl:template match="none"/></xsl:stylesheet>

Apparently earlier versions of Saxon, missed to change the prefix
of the last generated "template" element.

Result of Libxslt with the refactored code:
-------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" version="1.0">

  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

  <xsl:template match="xsl:stylesheet">
  	<xsl:copy>
  		<xsl:copy-of select="node()|@*"/>
  		<axsl:template match="none"/>
  	</xsl:copy>
  </xsl:template>

<xsl:template match="none"/></xsl:stylesheet>
Comment 3 kbuchcik 2006-08-10 09:46:13 UTC
Mark this bug as fixed when we switch to the refactored code paths.
Comment 4 GNOME Infrastructure Team 2021-07-05 11:00:39 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxslt/-/issues/

Thank you for your understanding and your help.