xml-xsp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Alm" <j...@ulmus.org>
Subject Nested calls to logicsheets
Date Thu, 27 Feb 2003 04:56:42 GMT
Hi,
I am new to Cocoon and I have a question about nesting logicsheet calls. The reason I want
to do this is that I generate all the content at run-time and as such I don't want to have
several definitions of how, for instance, an image should be presented. So what I want to
do is define templates that I call instead. The problem is some of the templates call other
templates.

My logicsheet looks something like this (simplified):

<?xml version="1.0"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsp="http://apache.org/xsp"
  xmlns:my="http://apache.org/xsp/my/1.0"
  >
    <xsl:template match="my:get-template">
        <xsl:variable name="name"/>
        <xsl:variable name="local"><xsl:value-of select="@name"/></xsl:variable>
        <whatever...>
            <xsl:copy-of select="//my:set-template[@name = $local]/*"/>
        <more whatever...>
    </xsl:template>
</xsl:stylesheet>
    
The document it transforms might look something like this:

<xsp:page language="java"
    xmlns:my="http://apache.org/xsp/my/1.0"
    xmlns:xsp="http://apache.org/xsp"
    >
    <my:set-template name="link">
        <xsp:logic>
            <Link particulars....>
            <my:context lookup="link"> // this is a database lookup through a helper
class
                if( this.link.anchor.type == image ) // this is based on the context
                {
                    <my:get-template name="image"/>
                }
                else if( this.link.anchor.type == text )
                {
                    <my:get-template name="text"/> // not shown here though
                }
                <my:something else...>
            </my:context>
        </xsp:logic>
    </my:set-template>
    <my:set-template name="image">
        <Image particulars, similar to link lookup, based on database lookup...>
    </my:set-template>

    <content>
        <my:get-template name="link"/>
        <my:get-template name="image"/>
        <my:get-template name="link"/>
        <my:get-template name="image"/>
        ...
        ...
    </content>

</xsp:page>

I can't seem to get the <my:get-template name="image"/> that is nested within the "link
template" to translate into anything. I have tried implementing it as a meta-stylesheet but
with no luck and I have also tried several other approaches. I have also tried different things
in the logicsheet instead of <xsl:copy-of .../> but nothing I do seems to work. Can
this be done in Cocoon? If so how? What approach should I look at? 

Anyone have a similar problem? Please help me. Any suggestions are welcome.

// Jens

jens@ulmus.org

Mime
View raw message