Subject: Re: [xsl] xsl:include blues.. From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 13 Feb 2001 10:38:46 +0100 (MET) |
Hi Kevin, yes, your XSLT must be well-formed XML. So you can't seperate opening and closing tags. You have to create them together (strictly spoken: you create an element). This can be done by using a named template: include.xsl ----------- <xsl:template name="frame"> <xsl:param name="content" /> <html> <head> </head> <body> <xsl:copy-of select="$content" /> </body> </html> </xsl:template> somepage.xsl ------------ <xsl:include file="include.xsl"/> <xsl:template match="ob"> <xsl:call-template name="frame"> <xsl:with-param name="content"> ... some HTML </xsl:with-param> </xsl:call-template> </xsl:template> Cheers, Oliver You wrote: > I am having two dilemas with using an XSL include. First, I want to include > a "header" and "footer" on every page. The header would be the opening HTML > (<html><head></head><body>), and the footer would be the closing > </body></html>. I thought of putting these in a "library" of templates, so > that I can match a <header> and <footer> tag in the source XML, but > apparently you have to close the tags you open even in a template. I figure > the resulting XML had to be well-formed. For example, here is a snippet of > xsl I thought would work: > > ----------- > include.xsl > ----------- > > <xsl:template match="header"> > <html> > <head> > </head> > <body> > </xsl:template> > > <xsl:template match="footer"> > </body> > </html> > </xsl:template> > > > ------------ > somepage.xsl > ------------ > > <xsl:include file="include.xsl"/> > > <xsl:template match="ob"> > <xsl:apply-templates select="header"/> > ... some HTML > <xsl:apply-templates select="footer"/> > </xsl:template> > > > I am not sure why the above doesn't work, but I assume its because the > templates must be well-formed? So the question is, how can I include the > same "header" and "footer" in every XSL page so that I can use a consistent > look to my site, but still get the benefits of using XSL? [...] /-------------------------------------------------------------------\ | ob|do Dipl.Inf. Oliver Becker | | --+-- E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx | | op|qo WWW: http://www.informatik.hu-berlin.de/~obecker | \-------------------------------------------------------------------/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Escaping Characters in Dy, Clapham, Paul | Thread | RE: [xsl] xsl:include blues.., Ben Robb |
RE: [xsl] XSLT 1.1 comments, Peter Flynn | Date | Re: [xsl] How do you get the most r, Jeni Tennison |
Month |