This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Using xsl:include when converting xsl to xsl
- To: "Tim Watts" <timw at 3d3 dot com>
- Subject: Re: [xsl] Using xsl:include when converting xsl to xsl
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Tue, 27 Feb 2001 12:12:30 +0000
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <001801c0a086$bfcb7de0$8c01a8c0@3d38kw1n0b1udc>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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