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

Re: xsl:include blues..

Subject: Re: xsl:include blues..
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Feb 2001 10:38:46 +0100 (MET)
xsl include xsl template
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

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.