OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: FW: How To Include external XSL files into a master XSL file

[ Lists Home | Date Index | Thread Index ]
  • From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
  • To: <xml-dev@xml.org>
  • Date: Sun, 13 Feb 2000 08:55:17 -0500

At 00/02/12 13:14 -0600, Jim Garrett wrote:
>What is the syntax to link multiple child style sheets into
>a master style sheet ...

I'll describe three ways in this response, even though your example points 
to only one way.  This question is better posted to

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

>header style sheet     header.xsl
>footer style sheet      footer.xsl
>data style sheet       data001.xsl
>master style sheet.  master.xsl
>this way i can always reference the master.xsl
>style sheet from any/all   *.xml files
>and then link in header.xsl (this one never changes)
>then the appropriate data.xsl (this one changes)
>then link the footer.xsl (this one never changes)
>this way if I make any changes to the header
>or the footer, they are edited in just one file
>and reflected in all master.xsl files
><?xml version='1.0'?>
><xsl:stylesheet xmlns:xsl="http://www.w3.org>
><xsl:template match="/">
><!-- include the header.xsl file here -->
><!-- how to include syntax here -->
><!-- include the data.xsl file here -->
><!-- how to include syntax here -->
><!-- include the footer.xsl file here -->
><!-- how to include syntax here -->

Your syntax above implies you want different snippets to be included in the 
root template, which can be done for the content of a single template, but 
I suspect you would rather want to include different sets of template rules 
into a single stylesheet.

If you must have a portion of a given template in an external file, you can 
use the XML external parsed general entities, but that syntactic scheme 
does not support reuse properly (though many coerce it to 
try).  Personally, I don't put portions of templates in external files, 
rather, I use the <xsl:call-template> construct to accomplish what you are 

There are two semantic inclusion schemes at the top level of a stylesheet 
(children of the stylesheet container element):  inclusion and importation.

You can use <xsl:include> to pull in top-level elements from another 
stylesheet and all such constructs are included as if they were edited 
in-situ (which sometimes can introduce problems accommodating template 
conflict resolution).

You can use <xsl:import> to pull in top-level elements from another 
stylesheet with the concept of "importance".  This confers more importance 
on the importing stylesheet constructs than on the imported stylesheet 
constructs, without conflict.  This is a powerful way to exploit an 
existing stylesheet with tweaks from an importing stylesheet.

>what is the proper syntax in the included external xsl files
>are they structured the same as the master.xsl file would
><?xml version='1.0'?>
><xsl:stylesheet xmlns:xsl="http://www.w3.org>
><xsl:template match="/">
><!-- this is the header xsl file -->

Yes (with the caveat that again you appear to misconstrue the use of the 
declaration of the template for the root node) for included and imported 
stylesheets, but no for external parsed general entities (which are merely 
well-formed).  Included and imported stylesheets are entire stylesheets in 
their own right.

If you are attending X-Tech in San Jose, I am teaching a two-day 
hands-on-with-exercises tutorial covering 100% of the constructs of 
XSLT.  Please see 
http://www.gca.org/attend/2000_conferences/xtech_2000/default.htm for 
registration information.  I am also teaching this material at other 
conferences (see our web site below for the conference course schedule) and 
companies in Europe, Japan and the U.S. are licensing our XSLT training 
materials for their own deliveries to their own customers.

I hope this helps.  You can get more input from many others if you post 
such a question to the list I noted at the top of this message.

.................. Ken

G. Ken Holman                    mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/x/
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-03-9
Next instructor-led training: 2000-02-27/28,2000-05-11/12,2000-05-15,
-                                    2000-06-12,2000-06-13,2001-01-27


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS