Using a variable for a template name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • littlefitzer

    #1

    Using a variable for a template name

    Hi,
    Say for example I want to use the following line in my XSL:
    <xsl:call-template name="buildText "/>

    I know I have to have a template defined named buildText.

    My question is:
    Is there a way to parse similarly named variables efficiently?
    To elaborate, I had a template called buildText that would build some
    text for me e.g.
    <xsl:template name="buildText ">
    <lineOne>
    <xsl:value-of select="$line"/>
    parse some other stuff too.....
    </lineOne>
    ....where line is defined as:
    <xsl:variable name="line" select="'LINE'"/>

    So that worked fine. Problem I now have is I have numerous lines I may
    need to parse, and they are named LINE_1, LINE_2, LINE_3 etc. and also
    maybe only LINE_1 and LINE_2 will be there and not LINE_3 and so on

    Is there a way I can do this using the same template, possibly using a
    variable?
    i.e. call buildText_1 to parse LINE_1, buildText_2 to parse LINE_2,
    but only have a single template defined called buildText?? where I can
    replace the ?? with _1 or _2 etc as needed?

    I hope this isn't too confusing. Thanks for any help,
    Scott
  • Andy Dingley

    #2
    Re: Using a variable for a template name

    On 5 Oct 2004 15:58:35 -0700, littlefitzer@ho tmail.com (littlefitzer)
    wrote:
    [color=blue]
    >I hope this isn't too confusing.[/color]

    Damn close to it ! Took me several passes to try and understand what
    you're asking for.

    I think that all you're after here is a parameter, passed to the
    template when you do the <xsl:call-template ... >
    Look up <xsl:with-parameter ... >

    --
    Smert' spamionam

    Comment

    • littlefitzer

      #3
      Re: Using a variable for a template name

      Thanks.
      That sounds like what I might be after...would you be able to give me
      an example? Sorry...fairly new to this.
      Thanks again,
      Scott

      Comment

      Working...