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

When not to <xsl:include>

Subject: When not to <xsl:include>
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Tue, 1 Jun 1999 22:23:31 -0600
not in xsl
<xsl:include> and <xsl:import> can only refer to complete stylesheets. Thus,
something like this is fine:

variables.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
	<xsl:variable name="Title" expr="/give/me/some/data"/>
	<xsl:variable name="Author" expr="'James Clark'"/>
</xsl:stylesheet>


stylesheet.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
	<xsl:include href="variables.xsl"/>
	<xsl:template match="/">
		<xsl:text>Title: </xsl:text><xsl:value-of select="$Title"/>
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>Author: </xsl:text><xsl:value-of
select="$Author"/>
	</xsl:template>
</xsl:stylesheet>

But what if I want to re-use the contents of the <xsl:template>? I can't use
the same method to import those from another file, because <xsl:text> and
<xsl:value-of> are not allowed at the top level of the stylesheet. Is using
external entity references the preferred method? And is this how to do it
(below)? This works, but I'd just like some confirmation that that's the way
it's supposed to be done.

[variables.xsl as above]

reusable_stuff.txt:
<xsl:text>Title: </xsl:text><xsl:value-of select="$Title"/>
<xsl:text>&#xA;</xsl:text>
<xsl:text>Author: </xsl:text><xsl:value-of select="$Author"/>

stylesheet.xsl:
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY ShowInfo SYSTEM 'reusable_stuff.txt'> ]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
	<xsl:include href="variables.xsl"/>
	<xsl:template match="/">
		&ShowInfo;
	</xsl:template>
</xsl:stylesheet>



 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.