Subject: Re: [xsl] Reusing and XPath expression From: Jacobus Reyneke <jacobusreyneke@xxxxxxxxx> Date: Thu, 3 Mar 2011 14:25:28 +0200 |
Thank you, gents. On Thu, Mar 3, 2011 at 2:06 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote: > > You seem to be looking for functions: > > <xsl:function name="f:depth" as="xs:integer"> > <xsl:param name="node" as="node()"/> > <xsl:sequence select="count($node/ancestor::*)"/> > </xsl:function> > > Michael Kay > Saxonica > > On 03/03/2011 11:56, Jacobus Reyneke 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: >> >> <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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Reusing and XPath express, Michael Kay | Thread | Re: [xsl] Reusing and XPath express, Dimitre Novatchev |
Re: [xsl] Problem accumulating valu, Patricia Santana Cru | Date | Re: [xsl] HST's answers Re: [xsl] E, Dimitre Novatchev |
Month |