xsl-list
[Top] [All Lists]

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

2009-02-11 11:22:00
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:template>

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

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 it’s 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:template>

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

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.



--~------------------------------------------------------------------
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>
--~--