Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how do I test for current XSL template?

Reply
Thread Tools

how do I test for current XSL template?

 
 
festo
Guest
Posts: n/a
 
      04-19-2007
Hi guys,

I need to print a different footer depending on the template being
printed. How do I test for the current template being processed in
XSLT?

Thanks,

fes

 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      04-19-2007
festo wrote:
> I need to print a different footer depending on the template being
> printed. How do I test for the current template being processed in
> XSLT?


There's no "what template is being processed" query in XSLT. You can use
parameters and modes to explicitly pass context information down to
other templates invoked from this one... but since I don't understand
from the description what you're actually trying to do, I can't advise
you on how to achieve it.

(In fact the concept of "current template" is somewhat flaky. Since
templates may be nested either as a result of an apply-templates action
or because they were explicitly invoked via call-templates. There may be
many "current" templates stacked up at any given time. If you mean the
most recent template, you don't have to test for it since you're in it...?)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
 
festo
Guest
Posts: n/a
 
      04-19-2007
On Apr 19, 11:31 am, Joseph Kesselman <(E-Mail Removed)>
wrote:
> festo wrote:
> > I need to print a different footer depending on the template being
> > printed. How do I test for the current template being processed in
> > XSLT?

>
> There's no "what template is being processed" query in XSLT. You can use
> parameters and modes to explicitly pass context information down to
> other templates invoked from this one... but since I don't understand
> from the description what you're actually trying to do, I can't advise
> you on how to achieve it.
>
> (In fact the concept of "current template" is somewhat flaky. Since
> templates may be nested either as a result of an apply-templates action
> or because they were explicitly invoked via call-templates. There may be
> many "current" templates stacked up at any given time. If you mean the
> most recent template, you don't have to test for it since you're in it...?)
>
> --
> Joe Kesselman / Beware the fury of a patient man. -- John Dryden



heres what I am trying to do.

<xsl:template name="template1Name">
.....
</xsl: template>

<xsl:template name="template2Name">
.....
</xsl: template>

I am already printing page number and I want to also print the
template name dynamically.
So I want to test which template is currently being processed while
doing the pagination,
then print its name in the footer together with page#.

eg template2Name page 2

thanks.

 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      04-19-2007
> I am already printing page number

Printing and pagination and footers aren't XSLT concept. They're handled
by whatever your next stage or processing is (XSL-FO processor or
browser or whatever else is consuming XSLT's output).

So what you need to do is find out what syntax the markup system you're
generating uses to alter the footer -- assuming this can be done on a
dynamic basis, which may not be correct -- and have the template
generate the appropriate markup to do so. You can't retrieve the
template's name; you have to hand-code that same string in the
appropriate place in the template's body.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      04-25-2007
Joseph Kesselman wrote:
>You can't retrieve the
> template's name; you have to hand-code that same string in the
> appropriate place in the template's body.


.... Or, just to point out an alternative: You could write a stylesheet
for styling stylesheets which implements a syntax what retrieves the
template's name. See my two-part article on DeveloperWorks for an
illustration of what techniques would be involved.


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
TEST TEST Test...Blah Blah Blah Generalbatguano@pacbell.net Computer Support 6 09-13-2006 01:53 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
TEST TEST TEST Gazwad Computer Support 2 09-05-2003 07:32 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments