I have been banging my head against the wall on this one problem, and thought saxon experts might have some ideas.  (I’m using XSLT 2.0 for this project..)

 

I have built up a variable that will help me locate a specific node in my document as follows:

 

<xsl:variable name="argument_xpath">/command<xsl:for-each select="remove(tokenize(path,'\s+'),1)">/parm_list/argument[name='<xsl:value-of select="."/>']</xsl:for-each>

 

Given the value of path is “clock set time”,

The result of the code above is:

/command/parm_list/argument[name='set']/parm_list/argument[name='time']”

 

However, I can not for the life of me figure out how to get this to be parsed by Saxon as an xpath expression instead of a string value:

<xsl:for-each select=”’$argument_xpath’”> . . .

Does not work, nor does the variation:

<xsl:for-each select=”’/command/$argument_xpath’”> . . (Assuming I truncated the variable so this is a correct xpath that will find the target node.)

 

I can of course use variables within an xpath expression, in some contexts:

//command[name=’$x’] for example works like a charm.

 

Any hints or ideas on how to get Saxon to treat an entire $variable as an xpath expression to be evaluated against the main document?

 

 

Tom