Project

Profile

Help

extension function invoking apply-templates

Added by Anonymous over 16 years ago

Legacy ID: #5057168 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

Hello! Is there any legal way to invoke xsl:apply-templates and pass xsl:param to that call from extension function? I'm playing with my reincarnation of try/catch in xslt and want to create an extension function that does the following: function tryBlock(tryItems, catchItems) { try { execute xsl:apply-templates for tryItems. } catch { execute xsl:apply-templates for catchItems with error info as params. } } At present I have not found a good solution to this, and use additional extension function returning error info during catch phase. The example is on my blog: http://www.nesterovsky-bros.com/weblog/2008/06/26/TrycatchBlockInXslt20ForSaxon9.aspx Thanks.


Replies (3)

Please register to reply

RE: extension function invoking apply-templat - Added by Anonymous over 16 years ago

Legacy ID: #5057399 Legacy Poster: Michael Kay (mhkay)

I'm not sure how to interpret "legal". You're going to have to use some fairly low-level interfaces, and when you do that it's at your own risk, but I don't try to tell users what's legal and what isn't. (And I don't use the verb "supported", because nothing is supported). I would think that the static method ApplyTemplates.applyTemplates() gives you everything you need for this.

RE: extension function invoking apply-templat - Added by Anonymous over 16 years ago

Legacy ID: #5057474 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

Sorry for my poor explanation. > I'm not sure how to interpret "legal". I'm trying to use Saxon api marked with @since tag. > I would think that the static method > ApplyTemplates.applyTemplates() gives > you everything you need for this. Yes, I'm using ApplyTemplates.applyTemplates(): XPathContextMajor majorContext = XPathContextMajor.newContext(minorContext); TailCall tailCall = ApplyTemplates.applyTemplates( catchItems, mode, ParameterSet.EMPTY_PARAMETER_SET, tunnelParameters, majorContext, false, 0); while(tailCall != null) { tailCall = tailCall.processLeavingTail(); } I have not found how can I construct and populate a new ParameterSet instance. In particular how can I pass: $error as xs:QName; $error-description as xs:string; ...

RE: extension function invoking apply-templat - Added by Anonymous over 16 years ago

Legacy ID: #5057518 Legacy Poster: Michael Kay (mhkay)

>I'm trying to use Saxon api marked with @since tag. I'm afraid for an extension that goes as deep as try/catch, you'll need to use internal interfaces that are subject to change. >I have not found how can I construct and populate a new ParameterSet instance. I see the problem: the parameters are not identified by name, but by number. You'll have to get in at compile time and either discover what parameter numbers are allocated to $error-code, etc, or allocate the numbers yourself (by calling allocateUniqueParameterNumber() on the XSLStylesheet object representing the principal stylesheet module)

    (1-3/3)

    Please register to reply