This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Using !ENTITY to include html
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Using !ENTITY to include html
- From: "Tim Watts" <timw at 3d3 dot com>
- Date: Thu, 30 Aug 2001 13:31:47 +1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Oliver,
How I have been adding the html to the top of my style sheets is by calling
the html template like so
XSL
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="document.xsl" />
*** <xsl:param name="title"><xsl:value-of
select="$language/ld-settings"/></xsl:param>
<xsl:template name="body">
...
</xsl:template>
</xsl:stylesheet>
and in document.xsl I have...
XSL INCLUDE
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*"/>
<xsl:template match="document">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
*** <title><xsl:value-of select="$title"/></title>
</head>
<body>
<xsl:call-template name="body"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This saves me recreating the html wrapping tags for the page each time, yet
allows me to pass params for use in the header tags (ie. the title
Hope that that has helped,
Tim Watts :)
> -----Original Message-----
> From: Thomas B.Passin
>
> [dante]
> >
> > I've been trying to use the following code in the beginning
> of my XSL to
> add
> > some html to my output document:
> >....
> > <xsl:template match="/">
> > <html>
> > <head>
> > <title>&title;</title>
> > etc.
>
>
> If you are trying to insert snippits of text into the result,
> you are better
> off using document(). For example, you could put the title into an
> ***xml*** file like this:
>
> File resources.xml:
>
> <resources>
> <title>This is My Best Work</title>
> <!--=== Typically you'd have other data here too ===-->
> </resources>
>
> Then in the stylesheet:
>
> ...
> <xsl:variable name='resources' select='document("resources.xml")/>
>
> <xsl:template match="/">
> <html>
> <head>
> <title><xsl:value-of select='$resources/title'/></title>
> etc.
>
> If you want to insert a whole branch of a tree, use <xsl:copy-of
> select='$resources/theBranch'/>
>
> This way is more robust for use with xslt, and is a lot more
> flexible than
> defining entities for everything.
>
> Cheers,
>
> Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list