xsl-list
[Top] [All Lists]

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

2009-05-20 09:58:57
At 2009-05-20 09:48 -0400, mlcook(_at_)Wabtec(_dot_)com 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(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>