|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using !ENTITY to include html
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








