import vs include and how to use

import vs include and how to use

Post by johka » Fri, 04 Jul 2003 10:30:03



I have an XSL file transforming perfectly.  Now I would like to break it up
by taking the "static" header navigation, left navigation and footer out of
the XSL so that I can reuse it across 12-15 XSL templates.  I am a newbie to
XSL and am just not getting the posts I have seen to this group on the
topic.    Note that the parts I want to take out currently do not have XSL
tags...just static HTML.

I tried using import and then call-template to get it brought into the page.
Can some point me in the right direction or give me a simplistic example?

Thank you, John

 
 
 

import vs include and how to use

Post by Colin Mackenzi » Fri, 04 Jul 2003 17:47:39


a simple example would be something like

main.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:include href="head.xsl"/>
 <xsl:include href="left.xsl"/>

 <xsl:template match="/">
        <html>
            <body>
                <xsl:call-template name="headDiv"/>
                <xsl:call-template name="LeftDiv"/>
                <xsl:apply-templates select="Data"/>
            </body>
        </html>
  </xsl:template>

    etc..

head.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template name="headDiv">
        <div class="Head">
            Lots of HTML Headers stuff
        </div>
  </xsl:template>

left.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template name="leftDiv">
        <div class="left">
            Lots of HTML TOC stuff
        </div>
  </xsl:template>

Colin


Quote:> I have an XSL file transforming perfectly.  Now I would like to break it
up
> by taking the "static" header navigation, left navigation and footer out
of
> the XSL so that I can reuse it across 12-15 XSL templates.  I am a newbie
to
> XSL and am just not getting the posts I have seen to this group on the
> topic.    Note that the parts I want to take out currently do not have XSL
> tags...just static HTML.

> I tried using import and then call-template to get it brought into the
page.
> Can some point me in the right direction or give me a simplistic example?

> Thank you, John


 
 
 

import vs include and how to use

Post by johka » Sat, 05 Jul 2003 05:11:50


Thank you Colin.  I got it working.   I was using template match instead of
name in the include.  Doh.  Still learning the syntax.

John


> a simple example would be something like

> main.xsl

> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
>  <xsl:include href="head.xsl"/>
>  <xsl:include href="left.xsl"/>

>  <xsl:template match="/">
>         <html>
>             <body>
>                 <xsl:call-template name="headDiv"/>
>                 <xsl:call-template name="LeftDiv"/>
>                 <xsl:apply-templates select="Data"/>
>             </body>
>         </html>
>   </xsl:template>

>     etc..

> head.xsl

> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

>  <xsl:template name="headDiv">
>         <div class="Head">
>             Lots of HTML Headers stuff
>         </div>
>   </xsl:template>

> left.xsl

> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

>  <xsl:template name="leftDiv">
>         <div class="left">
>             Lots of HTML TOC stuff
>         </div>
>   </xsl:template>

> Colin



> > I have an XSL file transforming perfectly.  Now I would like to break it
> up
> > by taking the "static" header navigation, left navigation and footer out
> of
> > the XSL so that I can reuse it across 12-15 XSL templates.  I am a
newbie
> to
> > XSL and am just not getting the posts I have seen to this group on the
> > topic.    Note that the parts I want to take out currently do not have
XSL
> > tags...just static HTML.

> > I tried using import and then call-template to get it brought into the
> page.
> > Can some point me in the right direction or give me a simplistic
example?

> > Thank you, John