Re: [xsl] Reusing and XPath expression

Subject: Re: [xsl] Reusing and XPath expression
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 3 Mar 2011 05:40:40 -0800
> In XPath 3.0 you can use inline function items (dynamically generated
> function definitions).
>
> See an example of this here:
>
>
http://dnovatchev.wordpress.com/2011/02/08/the-binary-search-tree-data-struct
urehaving-fun-with-xpath-3-0/
>
> and here:
>
>
>
http://dnovatchev.wordpress.com/2011/02/20/the-set-datatype-implemented-in-xp
ath-3-0/


Because this has become possible, the right question now is: Can we
persists a set of (any) XPath function thus defined  -- such as in a
file, so that we have in XPath something similar to the xsl:include
(at least) feature?

>
>
>
> Cheers,
> Dimitre Novatchev
> ---------------------------------------
> Truly great madness cannot be achieved without significant intelligence.
> ---------------------------------------
> To invent, you need a good imagination and a pile of junk
> -------------------------------------
> Never fight an inanimate object
> -------------------------------------
> You've achieved success in your field when you don't know whether what
> you're doing is work or play
> -------------------------------------
> Facts do not cease to exist because they are ignored.
>
>
>
>>
>> B  B <xsl:template match="cv:*/gl:title">
>> B  B  B  B <xsl:variable name="ancestors" select="count(ancestor::*)"/>
>> B  B  B  B <fo:block>
>> B  B  B  B  B  B <fo:inline
font-size="{($title-font-size)-2*$ancestors}pt">
>> B  B  B  B  B  B  B  B <xsl:apply-templates></xsl:apply-templates>
>> B  B  B  B  B  B </fo:inline>
>> B  B  B  B </fo:block>
>> B  B </xsl:template>
>>
>> In this example I resize the section titles in FO depending on the
>> depth of the title. Is there some way I can put the
>> "count(ancestor::*)" expression in one place and so re-use it in
>> different templates by 'calling' it? I cannot just make the expression
>> 'global' because new values cannot be assigned to it.
>>
>> This is just a question in an attempt to understand the mechanism of
>> re-using bits of XPath in an attempt to keep templates maintainable.
>>
>> Kind regards,
>> Jacobus
>>
>>
>
>
>
> --
>



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.

Current Thread