473,466 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how do I test for current XSL template?

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
4 1730
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: kmunderwood | last post by:
I am trying to combine "if match=" and "when test" I am a newbie, and have made both work separately, but I can not seem to combine them. This is my xml("index.xml")page(I can not change this,...
4
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work)...
7
by: Robert Allan Schwartz | last post by:
Why do I get a syntax error below? I don't see why volatile works but unsigned does not work. I'm not looking for an answer of the form, "Because the Standard says so", or "Because the C++...
0
by: Brian Basquille | last post by:
Hello all.. Is there any easy way to convert C++ to C#? I've got an inaccurate collision in my Air Hockey game and i've realised it's because i need to perform a sweep-test to get the precise...
5
by: Little | last post by:
I have this program and I need to work on the test portion, which tests if a Val is in the list. It returns false no matter what could you look at the part and see what might need to be done to fix...
1
by: aidy | last post by:
Hi I have some xml that is similar to this <testresults> <test id="test_1"> <description>demo test method 1</description> <teststatus>PASS</teststatus> </test> <test id="test_2">
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
4
by: David Sanders | last post by:
Hi, I have a class with an integer template parameter, taking values 1, 2 or 3, and a function 'calc' in that class which performs calculations. Some calculations need only be performed if the...
0
by: Malcolm Dew-Jones | last post by:
I have a test= that works but I would like to figure out how to move it into a match=. (Ok, that's unclear but pls keep reading.) Part of my XSLT file looks like this. <xsl:template...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.