This change happened because Saxon is gradually becoming more like a compiler and less like an interpreter. For example, if a global variable is not referenced anywhere in the "explicit" stylesheet code, then no code is generated for that global variable. I don't want to evaluate the variable and keep it around at run-time just in case someone decides to access it using saxon:evaluate.
 
saxon:evaluate is still available, of course, but it now has a much more constrained static and dynamic context, rather than inheriting these from the place in the stylesheet where it appears.
 
I think the right design in your case is different. Instead of having lots of variables, you should be using one variable whose value is an XML document containing structured information, and you should access the structured information using path expressions.
 
Michael Kay
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Roorda, Dirk
Sent: 24 June 2003 08:47
To: saxon-help@lists.sourceforge.net
Subject: [saxon] saxon:evaluate from 7.4 onwards

In saxon 6.5.2 there is the wonderful saxon:evaluate(string) for dynamic evaluation of expressions.
In saxon 7.4 the functionality of this extension has been limited: you can not say any more things like this:
 
saxon:evaluate(concat('$', $variablename))
 
Now I am writing generic stylesheets for XSLFO typesetting of books. I use 5000 xsl:variable elements, which are read by some generic stylesheets. The generic stylesheets rely heavily on dynamic fetching of these values, in fact, they are smaller in size than the <xsl:variable name="x" select="'y'"/> statements together!
 
As an example, many different parts in a book require an inline layout, so I have a lot of variables
like
 
<xsl:variable name="front-matter-paragraph.font-family" select="'10pt'"/>
<xsl:variable name="front-matter-paragraph.font-weight" select="'normal'"/>
<xsl:variable name="front-matter-paragraph.font-style" select="'normal'"/>
<xsl:variable name="front-matter-paragraph.font-variant" select="'normal'"/>
 
<xsl:variable name="seclevel1-heading.font-family" select="'18pt'"/>
<xsl:variable name="seclevel1-heading.font-weight" select="'bold'"/>
<xsl:variable name="seclevel1-heading.font-style" select="'normal'"/>
<xsl:variable name="seclevel1-heading.font-variant" select="'small-caps'"/>
 
In order to use these variables, I have a generic template setup-font that needs only one parameter:
the kind of text to be formatted:
 
<xsl:call-template name="setup-font">
    <xsl:with-param name="kind" select="'seclevel1-heading'"/>
</xsl:call-template>
 
It is only possible to write such a generic template using the saxon-6.5.2:evaluate:
 
<xsl:template name="setup-font">
    <xsl:param name="kind"/>
    <xsl:variable name="family" select="saxon:evaluate(concat('$', $kind, '.font-family'))"/>
    <xsl:variable name="weight" select="saxon:evaluate(concat('$', $kind, '.font-weight'))"/>
    <xsl:variable name="style" select="saxon:evaluate(concat('$', $kind, '.font-style'))"/>
    <xsl:variable name="variant" select="saxon:evaluate(concat('$', $kind, '.font-variant'))"/>
</xsl:template>
 
As you can see, the 7.4 restriction on saxon:evaluate will prevent me painfully from modularizing my stylesheets.
 
My question: can we hope to see the full force of saxon:evaluate back again in the future, or, is there some way around this?
 
Dirk Roorda