[xml/sgml-pkgs] Bug#468871: xsltproc: namespace-alias doesn't work

Daniel Dickinson cshore at wightman.ca
Sun Mar 2 01:45:11 UTC 2008


Package: xsltproc
Version: 1.1.22-1
Severity: normal


In order to produce a stylesheet from xml and a stylesheet one needs to use a namespace prefix other than xsl:.  This is typically turned into a useable stylesheet by using namespace-alias, unfortunately it doesn't do anything with xsltproc.


The following example produces the following error when trying to use the result stylesheet on another xml file:

compilation error: file test.xsl line 2 element stylesheet
xsltParseStylesheetProcess : document is not a stylesheet

Replacing <gconf:stylesheet xmlns:gconf="..."> with <xsl:stylesheet xmlns:gconf="..." xmlns:xsl="..."> (and corresponding closing tag), works.

An example stylesheet snippet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:gconf="output.xsl" >

  <xsl:namespace-alias stylesheet-prefix="gconf"
		       result-prefix="xsl" />
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <gconf:stylesheet xmlns:gconf="http://www.w3.org/1999/GCONF/Transform"
		      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		      version="1.0">
      <gconf:output method="xml" />
      <gconf:template match="/">
	<xsl:apply-templates select="gconf" />
      </gconf:template>
    </gconf:stylesheet>
  </xsl:template>
  <xsl:template match="/gconf">
   <gconf>
      <xsl:apply-templates />
    </gconf>
  </xsl:template>
  <xsl:template match="*[@name]">
    <xsl:element name="gconf:choose">
      <xsl:element name="gconf:when">
	<xsl:attribute name="test">not(<xsl:value-of select="name(.)" />[@name='<xsl:value-of select="@name" />'])</xsl:attribute>	
	<xsl:element name="{name(.)}">      
	  <xsl:for-each select="@*">
	    <xsl:attribute name="{name(.)}">
	      <xsl:value-of select="." />
	    </xsl:attribute>
	  </xsl:for-each>
	  <xsl:apply-templates />
	</xsl:element>   
	<xsl:element name="gconf:otherwise">


With some XML:

<gconf>
	<dir name="apps">
	        <dir name="panel">
			<dir name="applets">
				<dir name="system_monitor_screen0">
					<dir name="prefs">
						<entry name="view_diskload" schema="/schemas/apps/multiload/prefs/view_diskload" type="bool" value="true">
						</entry>
						<entry name="view_cpuload" schema="/schemas/apps/multiload/prefs/view_cpuload" type="bool" value="true">
						</entry>
						<entry name="view_netload" schema="/schemas/apps/multiload/prefs/view_netload" type="bool" value="true">
						</entry>
					</dir>
				</dir>
			</dir>
		</dir>
	</dir>
</gconf>

And some of the output:

<?xml version="1.0"?>
<gconf:stylesheet xmlns:gconf="http://www.w3.org/1999/GCONF/Transform" version="1.0">
  <gconf:output method="xml"/>
  <gconf:template match="/">
    <gconf xmlns:gconf="http://www.w3.org/1999/XSL/Transform">
	<gconf:choose xmlns:gconf="output.xsl"><gconf:when test="not(dir[@name='apps'])"><dir name="apps">
		<gconf:choose><gconf:when test="not(dir[@name='panel'])"><dir name="panel">
			<gconf:choose><gconf:when test="not(dir[@name='general'])"><dir name="general">
				<gconf:choose><gconf:when test="not(entry[@name='applet_id_list'])"><entry name="applet_id_list" type="list" ltype="string">

					<li type="string">
						<stringvalue>system_monitor_screen0</stringvalue>
					</li>	
					<li type="string">
						<stringvalue>drive_mounter_screen0</stringvalue>


The proper behaviour is defined in XSLT section 7.1.1

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.24-1-686 (SMP w/1 CPU core)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages xsltproc depends on:
ii  libc6                      2.7-6         GNU C Library: Shared libraries
ii  libgcrypt11                1.4.0-3       LGPL Crypto library - runtime libr
ii  libxml2                    2.6.31.dfsg-1 GNOME XML library
ii  libxslt1.1                 1.1.22-1      XSLT processing library - runtime 

xsltproc recommends no packages.

-- no debconf information





More information about the debian-xml-sgml-pkgs mailing list