tags:

views:

132

answers:

4

Is it possible to pass a path such as subject/name to a template then to use that path which is passed in the template as a path and not as a textual string. I am finding that the path is treated as text rather than a path.

A: 

There is no path data type in XPath or XSLT, so no. What sort of operations do you want to perform on this parameter? Get information about the file that the path points to?

jelovirt
This answer is flagged as correct? It is at best a partial answer and given the number of questions in the answer I guess the author is of the same opinion. Other posts list possibilities like dyn:evaluate that do allow 'dynamic' behaviour (at the cost of not being 'standard XSLT' anymore).
GerG
+1  A: 

There is an EXSLT extension function dyn:evaluate() that evaluates a string value as an XPath expression and returns the result (e.g. a nodeset)--see the EXSLT reference page. According to that page, libxslt, Xalan-J, and 4XSLT implement that function. Saxon also implements it but in its own namespace rather than in EXSLT's.

ChuckB
A: 

Saxon implements this the extension functions, saxon:evaluate() and saxon:evaluate-node().

James Sulak
+1  A: 

I depends what you're trying to do. If the path points to an xml file, then you can use the document(filename) syntax to put the contents of the file into an xsl variable.

<xsl:varialble name="myvar" select="document(somepath)/somenode" />

Take care here, firstly that the file exists, and secondly beware of msxml security settings in the latest parser that by default restrict you from accessing other documents.

Richard A