[xsl] Using xsl:namespace-alias for XSL generation in Saxon 6.5.3

Subject: [xsl] Using xsl:namespace-alias for XSL generation in Saxon 6.5.3
From: John Dawson <john.dawson@xxxxxxxxx>
Date: Mon, 2 Aug 2004 17:50:19 -0500
Hi!

I would love to be able to use namespace aliasing to
conveniently write XSL that generates more XSL.  I've got an
incantation for this that seems to work on many different
XSL processors (including Saxon 7.9.1), but not on the one
processor that I am constrained to use, Saxon 6.5.3.

Input XML:

  <doc/>

Input XSL:

  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                  xmlns:emit="map_to_xsl">
  <xsl:output method="xml" indent="yes"/>
  <xsl:namespace-alias stylesheet-prefix="emit"
                       result-prefix="xsl"/>

  <xsl:template match="/">
      <emit:stylesheet version="1.0"
                       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
      <emit:output method="xml" indent="yes"/>
      <emit:template match="/">
          <foo>
          </foo>
      </emit:template>
      </emit:stylesheet>
  </xsl:template>

  </xsl:stylesheet>

What I'd like for this to produce, and what it does seem to
produce with most XSL processors:

  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
     <xsl:output method="xml" indent="yes"/>
     <xsl:template match="/">
        <foo/>
     </xsl:template>
  </xsl:stylesheet>

What Saxon 6.5.3 produces:

  <?xml version="1.0" encoding="utf-8"?>
  <emit:stylesheet xmlns:emit="http://www.w3.org/1999/XSL/Transform";
                   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                   version="1.0">
     <emit:output method="xml" indent="yes"/>
     <emit:template match="/">
        <foo/>
     </emit:template>
  </emit:stylesheet>

I have found a few posts with Michael Kay trying to explain
Saxon 6.5.3's behavior for xsl:namespace-alias and
exclude-result-prefix.  I freely admit that I can't
understand the answers, apart from the gist:  "Sorry, the
XSL 1.0 spec doesn't say what namespace the serializer has
to output, so whatever Saxon 6.5.3 does is by definition
conformant."  (I'm paraphrasing)

I can accept this, but I can't help but think that there is
some way to get Saxon 6.5.3 do what I want.  I can tell that
Michael is an extremely smart guy and that Saxon is
high-quality software, and this seems like an obvious thing
to want to do.  All the xsl:element and xsl:attribute
verbiage gets tedious and hard to read when it's generating
more XSL for output.  Thus I'm hopeful it can do it somehow.

Any assistance appreciated.

John

Current Thread