Re: [xsl] Obtaining the name of a template while executing the template

Subject: Re: [xsl] Obtaining the name of a template while executing the template
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 May 2009 09:58:21 -0400
At 2009-05-20 09:48 -0400, mlcook@xxxxxxxxxx wrote:
I can't find the answer to my question in the references I have at hand,
or am overlooking the obvious.

I'd like to get the name of a template while executing that template,
and using the name in an error message.

That information is not available in standard XSLT ... look to any vendor extensions that may offer this.


I think I want something like:

<xsl:message>Error in template <xsl:something here to get the template's
name/>, bad value for <xsl:value-of select="$myvar" /></xsl:message>

Suggestions or alternatives?

Just hardwire the name ... you are already in the template when you write the message.


If you move the message to a standalone template, then from the template you are in just pass the name as a string value to the standalone template. Given that the names of templates don't change during processing, the value you are looking for is statically known and need not be made available dynamically for execution.

I hope this helps.

. . . . . . . . . . Ken

--
XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread