Using a variable for a template name

Discussion in 'XML' started by littlefitzer, Oct 5, 2004.

  1. littlefitzer

    littlefitzer Guest

    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
    littlefitzer, Oct 5, 2004
    #1
    1. Advertising

  2. littlefitzer

    Andy Dingley Guest

    On 5 Oct 2004 15:58:35 -0700, (littlefitzer)
    wrote:

    >I hope this isn't too confusing.


    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
    Andy Dingley, Oct 6, 2004
    #2
    1. Advertising

  3. littlefitzer

    littlefitzer Guest

    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
    littlefitzer, Oct 6, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bobby Chamness
    Replies:
    2
    Views:
    2,380
    Joe Smith
    Apr 22, 2007
  2. mfglinux
    Replies:
    11
    Views:
    685
    Roberto Bonvallet
    Sep 12, 2007
  3. Johannes Schaub (litb)
    Replies:
    3
    Views:
    327
    Victor Bazarov
    Sep 10, 2010
  4. Peter Buckley
    Replies:
    5
    Views:
    194
    matt neuburg
    Feb 27, 2009
  5. David Filmer
    Replies:
    19
    Views:
    227
    Kevin Collins
    May 21, 2004
Loading...

Share This Page