RE: [xsl] Identity transform of stylesheet

Subject: RE: [xsl] Identity transform of stylesheet
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 7 Apr 2003 19:18:02 +0100
> I need to perform an identity transform on a stylesheet to 
> add an attribute to each and every LRE.  The stylesheet(s) 
> are of the form:
> 
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:include href="foo.xsl"/>
> <xsl:template match="/">
>   <xsl:apply-templates/>
> </xsl:template>
> </xsl:stylesheet>
> 
> The issue is performing the transform after all of the 
> includes/imports of the xsl have been processed, rather that 
> just the 6 line xml document.

If the above is your source document, then it is just data, so there is
no sense in which any xsl:include and xsl:import elements are going to
be "processed, other than being processed in the same way as any other
element in the source document.

If you want to apply the same transformation to the above document and
to all the documents referenced (recursively) by xsl:include and
xsl:import elements you can do:

<xsl:template match="xsl:stylesheet | xsl:transform">
  <xsl:apply-templates select="." mode="add-attributes"/> 
  <xsl:for-each select="document(xsl:include/@href | xsl:import/@href)">
     <xxx:result-document href=".">
       <xsl:apply-templates select="*"/>
     </xxx:result-document>
  </xsl:for-each>
</xsl:template>


Where xxx:result-document is an extension element provided by your
processor to produce multiple output files.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> Ideally, I would 
> like to be able to take the transformer object and process 
> that as xml... as that would be the entire stylesheet, but of 
> course Im more than likely talking rubbish here :)

Yes, there's no way you can reverse compile a transformer object to
produce XML.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread