xsl-list
[Top] [All Lists]

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

2010-12-23 08:37:19
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
comments.

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

Doesn?t (easily) know which rule to invoke so I'm using the template match
form.

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()"/>
          </xsl:call-template>


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 doesn?t 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()"/>
          </xsl:call-template>

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 !

Thanks.




----------------------------------------
David A. Lee
dlee(_at_)calldei(_dot_)com
http://www.xmlsh.org




----------------------------------------
David A. Lee
dlee(_at_)calldei(_dot_)com
http://www.xmlsh.org



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