[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using xsl:include when converting xsl to xsl

Subject: Re: Using xsl:include when converting xsl to xsl
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 27 Feb 2001 12:12:30 +0000
using xsl include
Hi Tim,

> I expected the xsl:template name="body", which is the HTML header
> information contained in functions.xsl, to be added to the resulting
> xsl file but this didn't happen.

The code outputted what I expected it to output, but that doesn't mean
that it's what you expected it to do :)  The only thing 'wrong' is
that the x:namespace-alias result-prefix should be 'x' rather than
'xsl':

<x:namespace-alias stylesheet-prefix="xsl" result-prefix="x"/>

so that the XSLT elements that you're producing are placed in the
correct namespace when they're output.

I think what you're after is a stylesheet that takes an existing
stylesheet with xsl:include elements in it as its source, and expands
the xsl:include elements in the same way as a normal processor would
do to create a result that's also an XSLT stylesheet.

Here is such a stylesheet:

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

<xsl:output method="xml" indent="yes"/>

<xsl:strip-space elements="*" />
<xsl:preserve-space elements="xsl:text" />

<!-- copy elements by default -->
<xsl:template match="*">
   <xsl:copy>
      <xsl:copy-of select="@*" />
      <xsl:apply-templates />
   </xsl:copy>
</xsl:template>

<!-- where there are include elements, apply templates to (i.e. copy)
     the content of the xsl:stylesheet element in the document that
     they reference -->
<xsl:template match="xsl:include">
   <xsl:apply-templates select="document(@href)/*/*" />
</xsl:template>

</xsl:stylesheet>
----

Note that the above *doesn't* deal properly with xsl:import elements,
but I guess that if you're having to do this with xsl:include then
you're not using xsl:import anyway.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.