You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jeff Sexton <js...@odshp.com> on 2002/12/12 19:12:05 UTC
Confused about xsl:include
This should be simple, but I'm not able to make it work.
Here's an xsl file, working fine:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Now">
<b>Date/Time:</b><xsl:apply-templates/>
</xsl:template>
... More templates ...
</xsl:stylesheet>
So what I do is take the "Now" template and put it in a separate file
called "other.xsl" and add an include like this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="stylesheets/other.xsl"/>
... More templates ...
</xsl:stylesheet>
Here's other.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Now">
<b>Date/Time:</b><xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
I know it's finding the other.xsl file because I get an exception if I use
an incorrect href. However, when using an include cocoon no longer
applies the "Now" template. This must be simple. What am I doing wrong?
Thanks for any and all tips!
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Confused about xsl:include
Posted by Jeff Sexton <js...@odshp.com>.
I have also tried using import instead, as in this fragment:
<xsl:import href="stylesheets/other.xsl"/>
<xsl:template match="Now">
<xsl:apply-imports/>
</xsl:template>
No matter what I do, templates in the included xsl file are not applied to
the output. No errors either, the templates just are not applied. If I
do nothing more than paste the template back into the main xsl file, it
works perfectly.
I'm trying to set up to do simple application-wide look and feel features,
like a banner across the top. An include/import would seem to be a good
way to do that. Other suggestions? What do others do?
On Thu, 12 Dec 2002, Jeff Sexton wrote:
> I have no <apply-template> nor parameters. All I'm doing is taking the
> documentation at face value in assuming that an xsl:include does a simple
> insert of another file in place. Is that not the case?
>
> I literally cut and paste a templete into a tiny file, and include it, but
> the template does not get applied.
>
>
> > > This should be simple, but I'm not able to make it work.
> > >
> > > Here's an xsl file, working fine:
> > >
> > > <?xml version="1.0"?>
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > >
> > > <xsl:template match="Now">
> > > <b>Date/Time:</b><xsl:apply-templates/>
> > > </xsl:template>
> > >
> > > ... More templates ...
> > >
> > > </xsl:stylesheet>
> > >
> > > So what I do is take the "Now" template and put it in a separate file
> > > called "other.xsl" and add an include like this:
> > >
> > > <?xml version="1.0"?>
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > >
> > > <xsl:include href="stylesheets/other.xsl"/>
> > >
> > > ... More templates ...
> > >
> > > </xsl:stylesheet>
> > >
> > > Here's other.xsl:
> > >
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > >
> > > <xsl:template match="Now">
> > > <b>Date/Time:</b><xsl:apply-templates/>
> > > </xsl:template>
> > >
> > > </xsl:stylesheet>
> > >
> > > I know it's finding the other.xsl file because I get an exception if I use
> > > an incorrect href. However, when using an include cocoon no longer
> > > applies the "Now" template. This must be simple. What am I doing wrong?
> > > Thanks for any and all tips!
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > Please check that your question has not already been answered in the
> > > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> > >
> > > To unsubscribe, e-mail: <co...@xml.apache.org>
> > > For additional commands, e-mail: <co...@xml.apache.org>
> >
> > --
> > Kind regards,
> > Yves Vindevogel
> >
> > Implements
> > Kortrijkstraat 2 bus 1 -- 9700 Oudenaarde -- Belgium
> > Phone/Fax: +32 (55) 45.74.73 -- Mobile: +32 (478) 80.82.91
> > Mail: yves.vindevogel@implements.be -- www.implements.be
> >
> > Quote: The winner never says participating is more important than winning.
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
> >
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Confused about xsl:include
Posted by Jeff Sexton <js...@odshp.com>.
On Thu, 12 Dec 2002, Yves Vindevogel wrote:
> Not 100% sure, but in my (humble) opinion, you can only call included
> templates and no longer use apply.
>
> Instead of <apply-template> you will need
>
> <xsl:for-each ...>
> <xsl:call-template select="mytemplate">
> <xsl:with-param name="myparamtopass" value="."/>
> </xsl:call-template>
> </xsl:for-each>
>
> in the included file:
> <xsl:template name="mytemplate">
> <xsl:param name="myparamtopass">
> ....
> </xsl:template>
I have no <apply-template> nor parameters. All I'm doing is taking the
documentation at face value in assuming that an xsl:include does a simple
insert of another file in place. Is that not the case?
I literally cut and paste a templete into a tiny file, and include it, but
the template does not get applied.
> > This should be simple, but I'm not able to make it work.
> >
> > Here's an xsl file, working fine:
> >
> > <?xml version="1.0"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:template match="Now">
> > <b>Date/Time:</b><xsl:apply-templates/>
> > </xsl:template>
> >
> > ... More templates ...
> >
> > </xsl:stylesheet>
> >
> > So what I do is take the "Now" template and put it in a separate file
> > called "other.xsl" and add an include like this:
> >
> > <?xml version="1.0"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:include href="stylesheets/other.xsl"/>
> >
> > ... More templates ...
> >
> > </xsl:stylesheet>
> >
> > Here's other.xsl:
> >
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >
> > <xsl:template match="Now">
> > <b>Date/Time:</b><xsl:apply-templates/>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > I know it's finding the other.xsl file because I get an exception if I use
> > an incorrect href. However, when using an include cocoon no longer
> > applies the "Now" template. This must be simple. What am I doing wrong?
> > Thanks for any and all tips!
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
>
> --
> Kind regards,
> Yves Vindevogel
>
> Implements
> Kortrijkstraat 2 bus 1 -- 9700 Oudenaarde -- Belgium
> Phone/Fax: +32 (55) 45.74.73 -- Mobile: +32 (478) 80.82.91
> Mail: yves.vindevogel@implements.be -- www.implements.be
>
> Quote: The winner never says participating is more important than winning.
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Confused about xsl:include
Posted by Yves Vindevogel <yv...@implements.be>.
Not 100% sure, but in my (humble) opinion, you can only call included
templates and no longer use apply.
Instead of <apply-template> you will need
<xsl:for-each ...>
<xsl:call-template select="mytemplate">
<xsl:with-param name="myparamtopass" value="."/>
</xsl:call-template>
</xsl:for-each>
in the included file:
<xsl:template name="mytemplate">
<xsl:param name="myparamtopass">
....
</xsl:template>
> This should be simple, but I'm not able to make it work.
>
> Here's an xsl file, working fine:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="Now">
> <b>Date/Time:</b><xsl:apply-templates/>
> </xsl:template>
>
> ... More templates ...
>
> </xsl:stylesheet>
>
> So what I do is take the "Now" template and put it in a separate file
> called "other.xsl" and add an include like this:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:include href="stylesheets/other.xsl"/>
>
> ... More templates ...
>
> </xsl:stylesheet>
>
> Here's other.xsl:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="Now">
> <b>Date/Time:</b><xsl:apply-templates/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> I know it's finding the other.xsl file because I get an exception if I use
> an incorrect href. However, when using an include cocoon no longer
> applies the "Now" template. This must be simple. What am I doing wrong?
> Thanks for any and all tips!
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
--
Kind regards,
Yves Vindevogel
Implements
Kortrijkstraat 2 bus 1 -- 9700 Oudenaarde -- Belgium
Phone/Fax: +32 (55) 45.74.73 -- Mobile: +32 (478) 80.82.91
Mail: yves.vindevogel@implements.be -- www.implements.be
Quote: The winner never says participating is more important than winning.
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>