[xsl] Dynamic dispatch of functions/templates (was matching text() )

Subject: [xsl] Dynamic dispatch of functions/templates (was matching text() )
From: "David Lee" <dlee@xxxxxxxxxxx>
Date: Thu, 23 Dec 2010 09:37:01 -0500
Still thinking how to change
            <xsl:apply-templates select="text()"/>

<xsl:template match="some_xpath/text()" >

Into something where the text is concatenated in the face of PI's or

I need (or think I do ) something that is dynamic dispatch.
That is, the code that generates
                        <xsl:apply-templates select="text()"/>

Doesnt (easily) know which rule to invoke so I'm using the template match

But suppose I could do the same thing with functions or named templates but
still let matching work ?
Then I could do something like

            <xsl:call-template name="????">
                        <xsl:value-of  select="string()"/>

I think I'm answering my own question  I need to generate unique names 
but maybe there's a way to mix these 2 modes ?  Call a fixed constant
template that has varients based on a match string ?
What I want is some rule that triggers on
<xsl:template match="some_xpath/string()" >

But that doesnt work, nor does mixing match= & call-template  (???)

Just shooting in the dark for ideas.  

My best one so far is to generate unique names for all the xpaths I need to
match and do an explicit static-dispatch on the template (or function) name

But maybe there's a "trick" to get templates to be dynamically dispatched by
name & context node ?
like (I know this isnt valid )

            <xsl:template name="format_striung"
match="some/xpath/expression" >

then call it with something like
            <xsl:call-template name="format_string" select=".">
                        <xsl:value-of  select="string()"/>

Maybe this is what "mode" or pass-through parameters are for ?

Not asking anyone to work on this problem, but if something obvious comes to
mind I'd love to hear it !


David A. Lee

David A. Lee

Current Thread