This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Limitations of Includes in XSL
- To: XSL List <XSL-List at mulberrytech dot com>
- Subject: Re: Limitations of Includes in XSL
- From: "G. Ken Holman" <gkholman at CraneSoftwrights dot com>
- Date: Tue, 25 Apr 2000 15:24:13 -0400
- Reply-To: xsl-list at mulberrytech dot com
At 00/04/25 13:52 -0500, Ken Burnside wrote:
>What I've been trying to do is a trick I've used as a web developer -- the
>metaphorical equivilant of server side includes in the XSL file. Rather
>than cut and paste a filing and disposition control table like this
>
>(Warning -- long code block that probably doesn't have enough space for its
>indents...)
...
>from XSL file to XSL file. Obviously, much was elided from the sample
>above, but the table is easily 60 lines of code, that's replicated through
>90% of what I'm working on.
>
>I'd prefer to put it as a separate file, and call it as such:
>
><xsl:include href="filingAndDispo.xsl">
>
>I'm running into two problems:
>
>1) The XML parser (FOP) says that I cannot use an include inside of a
>template. I'm trying to see if I can summon the include outside the
>template and call the results from within it, but I confess to floundering
>a lot.
Thankfully, it is quite straightforward. In your template, use
<xsl:call-template name="named-thingy"/>, and then at the top level
(between templates) you can <xsl:include> the stylesheet fragment that has
<xsl:template name="named-thingy"/>.
Personally, I use <xsl:import> rather than <xsl:include> as it allows me to
override what I'm importing (not possible with include, which may introduce
template conflicts) if I need to.
>2) The other issue I'm running into is passing the appropriate root
>document to the XSL widget that's called by the include.
That which is included or imported is a fully-formed XSLT stylesheet
itself, so its document element is either <xsl:stylesheet> or <xsl:transform>.
Once you get the hang of this, you can really exploit a lot of fragments
you create in different ways. It can save a lot of time on development and
on maintenance.
I hope this helps.
................... Ken
--
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
Web site: XSL/XML/DSSSL/SGML services, training, libraries, products.
Practical Transformation Using XSLT and XPath ISBN 1-894049-04-7
Next instructor-led training: 2000-05-02,2000-05-11/12,2000-05-15,
- 2000-06-12,2000-06-13,2001-01-27
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list