[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How can one get the name of a template or function?

Subject: How can one get the name of a template or function?
From: "Houghton,Andrew" <houghtoa@xxxxxxxx>
Date: Wed, 11 Feb 2009 11:20:33 -0500
 How can one get the name of a template or function?
I'm using Saxon as an XSL transform processor.  So I don't mind whether the
answer is specific to Saxon or is general to all XSL transform processors.
What I would like to do is to get the name of the current template or function
that is currently executing.  I realize that templates don't need to be named,
but in my case they will be named since I'm using xsl:call-template on them.
So for example I would like to do something like:

<xsl:template name="foo" as="item()*">
  <xsl:variable name="my-name" as="xsd:string" select="get-name()" />

<xsl:function name="bar" as="item()*">
  <xsl:variable name="my-name" as="xsd:string" select="get-name()" />

Where get-name() is some sort of function that will give me the name of the
template or function.  I don't really care if its a function or a template
that I have to call to get this information.  When looking over the list of
XPath function I don't see anything useful and I didn't see anything in
Saxon's extensions.  So my question is can this be done somehow?

BTW, I realize that I could do:

<xsl:template name="foo" as="item()*">
  <xsl:variable name="my-name" as="xsd:string" select="string('foo')" />

<xsl:function name="bar" as="item()*">
  <xsl:variable name="my-name" as="xsd:string" select="string('bar')" />

but I would prefer not to do that since when the name attribute changes, I
need to keep the variable in sync too.

Thanks, Andy.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.