xsl-list
[Top] [All Lists]

Re: [xsl] Reusing and XPath expression

2011-03-03 07:38:09
On Thu, Mar 3, 2011 at 3:56 AM, Jacobus Reyneke
<jacobusreyneke(_at_)gmail(_dot_)com> wrote:
Good day,

Is there some way to re-use just part of an XPath expression. Here I
made an attempt by assigning it to a variable, but the benefit of
doing it this way is very limited:


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-structurehaving-fun-with-xpath-3-0/

and here:


http://dnovatchev.wordpress.com/2011/02/20/the-set-datatype-implemented-in-xpath-3-0/



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.




   <xsl:template match="cv:*/gl:title">
       <xsl:variable name="ancestors" select="count(ancestor::*)"/>
       <fo:block>
           <fo:inline font-size="{($title-font-size)-2*$ancestors}pt">
               <xsl:apply-templates></xsl:apply-templates>
           </fo:inline>
       </fo:block>
   </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

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





--

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

<Prev in Thread] Current Thread [Next in Thread>