Your message dated Sun, 2 Mar 2008 17:11:47 +0100
with message-id <[EMAIL PROTECTED]>
and subject line Re: [xml/sgml-pkgs] Bug#468871: I found the source of the 
problem
has caused the Debian Bug report #468871,
regarding xsltproc: namespace-alias doesn't work
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)


-- 
468871: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468871
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
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="[EMAIL PROTECTED]">
    <xsl:element name="gconf:choose">
      <xsl:element name="gconf:when">
        <xsl:attribute name="test">not(<xsl:value-of select="name(.)" />[EMAIL 
PROTECTED]'<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([EMAIL 
PROTECTED]'apps'])"><dir name="apps">
                <gconf:choose><gconf:when test="not([EMAIL 
PROTECTED]'panel'])"><dir name="panel">
                        <gconf:choose><gconf:when test="not([EMAIL 
PROTECTED]'general'])"><dir name="general">
                                <gconf:choose><gconf:when test="not([EMAIL 
PROTECTED]'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



--- End Message ---
--- Begin Message ---
On Sun, Mar 02, 2008 at 10:51:36AM -0500, Daniel Dickinson wrote:
> It appears that xmlns="http://www.w3.org/1999/GCONF/Transform"; is being
> added to tags produced with xml:element, and since the tag I am doing
> that to is almost the root, the stylesheet is spit back almost
> unchanged.  There is a little processing, but so little I initially
> thought I was just getting the original stylesheet back.
> 
> I am attaching the files I use to produce the issue.
> 
> modify-gconf.xsl is the original stylesheet
> sensors.xml is the xml used along with with modify-gconf.xsl to produce
> the target stylesheet
> %gconf-tree.xml is the xml to be applied to the target stylesheet to
> get the final output.
> 
> Steps:
> 
> xsltproc modify-gconf.xsl sensors.xml >intermediate.xsl
> xsltproc intermediate.xsl %gconf-tree.xml >final.xml

So, the only problem is that xsl:namespace-alias doesn't work on
xsl:element created nodes, which is just normal because namespace-alias
is for literal result elements, cf.
http://www.w3.org/TR/xslt#literal-result-element

You need to either add a namespace attribute to your xsl:elements or
make them literate result elements, such as <gconf:choose/> instead of
<xsl:element name="gconf:choose"
namespace="http://www.w3.org/1999/XSL/Transform"/>

Mike


--- End Message ---

Reply via email to