By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

how do I test for current XSL template?

P: n/a
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

Apr 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Apr 19 '07 #2

P: n/a
On Apr 19, 11:31 am, Joseph Kesselman <keshlam-nos...@comcast.net>
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.

Apr 19 '07 #3

P: n/a
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
Apr 19 '07 #4

P: n/a
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
Apr 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.