Subject: RE: [xsl] How can one get the name of a template or function? From: John Laurence Poole <jlpoole56@xxxxxxxxx> Date: Thu, 28 Feb 2013 19:50:42 -0800 |
I'm resurrecting an old 2009 topic regarding getting the name of a template. I followed Michael's suggestion below and have successfully written an extension function that produces the names of the template in instances where the template is invoke through the xsl:call-template mechanism. I'd be happy to provide a how-to on how I accomplished this along with demonstration files if someone would like them; I suspect this is a very esoteric area and there would not be any takers on my offer. What I would like to have is the ability to get the name of a template in instances where the template is invoked via the match mechanism: xsl:apply-templates. This would be for instances where the template has a name attribute, e.g. name="template_ABC". I tried invoking my function similar to that below in a match situation and null was returned despite the fact that the template that matched had a name attribute. Any suggestions on how to approach this? I'm new to studying the internals of Saxon, but believe there must be some place where information about the templates is stored to be accessed by the parser for the match facility and that extending the properties of the storage model to include a name attribute in instances where a template does have a name attribute would be the way toapproach this. Maybe I'm barking up the wrong tree and the matching mechanism is not what I'm imagining? Thanks, John Poole here's the message I'm following up on: On 2009-02-11 11:57:49 Michael Kay posted to this list: If you're prepared to grovel around the depths of Saxon internals, you can write an extension function public static String getTemplateName(net.sf.saxon.expr XPathContext context) { try { return context.getOrigin().getObjectName().getDisplayName(); } catch (Exception err) { return null; } } and call it without any arguments as xx:getTemplateName(). Not tested. It will only give the template name if it was invoked using call-template. Should probably work for function calls as well. Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Processing XML with multi, Dan Vint | Thread | RE: [xsl] How can one get the name , Liam R E Quin |
Re: [xsl] Support for lookaround re, Liam R E Quin | Date | RE: [xsl] How can one get the name , Liam R E Quin |
Month |