This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Using xsl:include when converting xsl to xsl


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]