XSLT isn't quite that reflexive - there wouldn't be much point in declaring the variables dynamically as you couldn't reference them dynamically either (even with saxon:evaluate(), which doesn't give access to the stylesheet's variables, only to the variables $p1 - $p9 passed in as arguments to saxon:evaluate()).
 
The answer to this I think is simply to pass the parameter document into saxon:evaluate and reference its contents using path expressions:
 
<xsl:variable name="params" select="doc($PARAM-FILE)/param-list/param"/>
 
<xsl:value-of select="saxon:evaluate(xxx, $params)"
 
and inside the evaluated expression
 
$p1/param/*[name()=xxxx]
 
Michael Kay
http://www.saxonica.com/

From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Cary Millsap
Sent: 28 February 2005 22:46
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Using evaluate() to define a list of params

I would like to be able to slurp a list of name/type/value tuples from an external XML document, and then execute a loop to make all the assignments found in that external document. I really want to do this:

 

       <xsl:template name="process-parameters">

              <xsl:for-each select="doc($PARAM-FILE)/param-list/param">

                     <xsl:message>Processing <xsl:value-of select="@name"/>...</xsl:message>

 

                     <!-- Here's what I'm trying to do... -->

                     <xsl:variable name="@name" as="@as" select="."/>

                    

              </xsl:for-each>

       </xsl:template>

 

...But of course, the “name” and “as” attributes of the xsl:variable and xsl:param elements aren’t allowed to be defined dynamically.

 

I want to avoid maintaining the variable names in both the external XML document and in my XSLT. I feel like I ought to be able to use evaluate() to take me there, but it’s just not coming to me...

 

Thank you.

 

Cary Millsap
Hotsos Enterprises, Ltd.
http://www.hotsos.com
Nullius in verba

Upcoming events:
-
Hotsos Symposium 2005: March 6–10 Dallas
- Visit
www.hotsos.com for curriculum and schedule details...