RE: is there a "template" template?

Subject: RE: is there a "template" template?
From: "Wilson, James.W" <James.W.Wilson@xxxxxxxxxxxxx>
Date: Mon, 12 Jul 1999 12:49:50 -0500
you could use a named template, and call it from your 'generic' template:

<xsl:template name='text1'>
    <xsl:choose>
        <xsl:when test='control'>CONTROL</xsl:when>
        <xsl:when test='param1'>PARAM1</xsl:when>
        ...
    </xsl:choose>
</xsl:template>

<xsl:template match='CONTROL|PARAM1|...'>
    <xsl:text>&#10;&#10;</xsl:text>
    <xsl:call-template name='text1'/>
    <xsl:text>&#10;END</xsl:text>
</xsl:template>

James

-----Original Message-----
From: Aaron Fischer [mailto:fischer17@xxxxxxxx]
Sent: Monday, July 12, 1999 1:12 PM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Q: is there a "template" template?



I am trying to greatly simplify my XSL code.  

I have a basic template transformation:

<xsl:template match="control">
<xsl:text &#10; &#10;CONTROL&#10; &#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text &#10;END&#10; &#10;</xsl:text>
</xsl:template>

I need to apply this kind of template to literally hundreds of different
cells;  i.e. I have other cells which require the same kind of template,
except replace "control" with "[something else]".

At the moment I have a huge XSL file full of these little templates -- with
all of them doing the same thing under a different name.

Is there a way I can write a "template" template, and have my code
internally generate
the actual templates during compilation?  i.e I would have something like:

the "template" template:  PARAM1 - match specification
    PARAM2 - output text

<xsl:template match="PARAM1">
<xsl:text &#10; &#10;PARAM2&#10; &#10;</xsl:text>
<xsl:apply-templates/>
<xsl:text &#10;END&#10; &#10;</xsl:text>
</xsl:template>

make-template( "control", "CONTROL")
make-template( "output", "OUTPUT")
make-template( "blah", "whatever")

etc...

Basically, I'm looking for a template in the true sense of the word, as in
the C++ way.

All help appreciated,

Aaron

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread