Subject: Re: [xsl] Reusing and XPath expression From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Thu, 3 Mar 2011 05:37:37 -0800 |
On Thu, Mar 3, 2011 at 3:56 AM, Jacobus Reyneke <jacobusreyneke@xxxxxxxxx> 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-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/ 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 > > --
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Reusing and XPath express, Jacobus Reyneke | Thread | Re: [xsl] Reusing and XPath express, Dimitre Novatchev |
Re: [xsl] HST's answers Re: [xsl] E, Dimitre Novatchev | Date | Re: [xsl] Reusing and XPath express, Dimitre Novatchev |
Month |