xsl-list
[Top] [All Lists]

Re: [xsl] Single transformation using XSLT on-the-fly

2008-10-18 15:40:22
"Giacomo" == Giacomo  <giacgbj(_at_)xoom(_dot_)it> writes:

    >> Well, it rather depends upon your definition of a single
    >> transformation, and how much you are prepared to cheat.

    Giacomo> When I said "a single transformation" I meant applying
    Giacomo> the stylesheet only once. If the stylesheet is able to do
    Giacomo> other transformations it's right for me.


    >> But using an extension function means you aren't doing it in
    >> pure XSLT 2.0. Well, you didn't say pure.
    >> 
    >> Do you want an example?

    Giacomo> Of course, I'm not pure ;)

Well, here is the example I just wrote.

Testing it found a bug (so you can't run it), but I fixed the bug,
locally. The output was:

<?xml etc. ?>
Tested OK.

Change the xsl:value-of to xsl:sequence prints the XML, instead of the
contents.

This is the transformation:

<?xml version="1.0" encoding="utf-8"?>
<xsl:transform 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
    xmlns:gexslt="http://www.gobosoft.com/eiffel/gobo/gexslt/extension";
   xmlns:axsl="file://namespace.alias"
    version="2.0">

  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
  
  <xsl:template name="initial">
    <xsl:call-template name="build"/>
    <xsl:call-template name="run"/>
  </xsl:template>
  
  <xsl:template name="build">
    <xsl:result-document href="file:///home/colin/gestalt/generated.xslt">
      <axsl:transform version="2.0">
        <axsl:template match="/">
          <doc>
            Tested OK.
          </doc>
        </axsl:template>
      </axsl:transform>
    </xsl:result-document>
  </xsl:template>
  
  <xsl:template name="run">
    <xsl:variable name="generated" 
select="gexslt:transformation('file:///home/colin/gestalt/alias.xsl',doc('file:///home/colin/gestalt/system.xace'))"/>
    <xsl:value-of select="$generated"/>
  </xsl:template>

</xsl:transform>

This worked (after fixing the bug, which means you can't run it at
home), by first creating a symbolic link from

alias.xsl onto generated.xslt.

A real cheat.
-- 
Colin Adams
Preston Lancashire

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--