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

RE: Discovering the joys of xsl:include (Sovled!)

Subject: RE: Discovering the joys of xsl:include (Sovled!)
From: Lukas Svoboda <LukasS@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Apr 2001 17:03:24 +1200
cellpading stylesheet
Thanks to Tim Watts, Steve Muench and Josh Coltrane 
(from the XML list) for helping me with my include 
problems. For archive's sake I've documented the 
updated XSL files which now work perfectly:

XML File:

<?xml version="1.0"?>
<page_data>
  <header>
    <company_name>Company XYZ</company_name>
    <copyright>(C) Company XYZ, Blah Blah</copyright>
  </header>
  <products>
    <product>
      <product_id>1</product_id>
      <product_title>Product Title 1</product_title>
      <product_description>This is the description of the product
123456</product_description>
    </product>
    <product>
      <product_id>2</product_id>
      <product_title>Product Title 2</product_title>
      <product_description>This is the description of the product
435322</product_description>
    </product>
  </products>
</page_data>

XSL Main:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">

  <xsl:import href="header.xsl" />

  <xsl:template match="/">
 
  <html>
  <body>

    <xsl:apply-templates select="page_data/header" />
    <br/>
    <table border="1" cellpading="4" cellspacing="4" bordercolor="#ffffff"
bgcolor="#BBBBBB">
      <xsl:apply-templates select="page_data/products/product" />
    </table>

  </body>
  </html>

  </xsl:template>

  <xsl:template match="product">

    <tr>
      <xsl:apply-templates select="product_id" />
      <xsl:apply-templates select="product_title" />
      <xsl:apply-templates select="product_description" />
    </tr>

  </xsl:template>

  <xsl:template match="product_id">
    <td><b><font face="verdana" color="#000033" size="2"><xsl:value-of
select="../product_id"/></font></b></td>
  </xsl:template>

  <xsl:template match="product_title">
    <td><b><font face="verdana" color="#000033" size="2"><xsl:value-of
select="../product_title"/></font></b></td>
  </xsl:template>

  <xsl:template match="product_description">
    <td><b><font face="verdana" color="#000033" size="2"><xsl:value-of
select="../product_description"/></font></b></td>
  </xsl:template>

</xsl:stylesheet>

XSL Include File:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

  <xsl:template match="header">
     <font face="verdana" color="#000033" size="3"><xsl:value-of
select="company_name"/></font><br/>
     <font face="verdana" color="#000033" size="1"><xsl:value-of
select="copyright"/></font><br/>
  </xsl:template>

</xsl:stylesheet>

> -----Original Message-----
> From: Tim Watts [mailto:timw@xxxxxxx]
> Sent: Tuesday, 24 April 2001 4:16 p.m.
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Discovering the joys of xsl:include
> 
> 
> Hi Lukus,
> 
> I can't see an xsl:include in your stylesheet, but the <xsl:import
> href="header.xsl" /> should be immediatly under the 
> <xsl:stylesheet>tag.
> (currently it is in a template)
> 
> For example, in a stylesheet I happen to have open at the 
> moment, it is
> writen like so...
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:include href="document.xsl"/>
> <xsl:include href="common.xsl"/>
> 
>   <xsl:template match="/">
> ...
>   </xsl:template>
> etc.
> 
> The imports and includes must be defined before the templates.
> 
> Best of luck,
> Tim Watts :)

 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.