I have a situation in xsl where I had a param value that will be assigned some where in xslt transformation. But I get that param as a String , that param may contains a node a unbounded[0 or more repetitions] . How can I use param in for each as just any other xml content as used by any xpath expression.
Here is my sample xmls:
RetreiveData.xml
<soap-content>
------
<return>
<!--0 or more repetitions>-->
<data>
<startdate>12-12-12</startdate>
<enddate>12-12-13</enddate>
<nooftrans>5</nooftrans>
</data>
<data>
----
</data>
</soap=content>
This is my sample file which will be sent as param to xsl
xsl file:
<xsl style>
<param name ="retrieve"></param>
---
<xsl:for-each ="$retreive/return/data">
----do strufff
</xsl:for-each>
This was throwing an error . How can i travese to a node if it is param ?
I know this can be done using variable which is assigned to the path in a xml file . But that method is suggested in my scenario.
Can any one help me in solving this
Thanks in advance,
Eresh
It would help If your posted code was well formed XSLT but guessing what you meant, then if $retrieve is a single element name you can do
Note that XPath variables hold values not fragments of expressions. If
$retrieveheld the string"root"then$retrieve/return/datais notroot/return/data/it is"root"/return/datawhich is a syntax/type error as it is in most languages. If you have a string “x” in c or fortran, the expression “x” + 1 does not add one to the variable x. To do that you need an XPath parser available at run time. Some products have extensions for that (and there is an evaluate function proposed for XPath 3) But for simple cases the above avoids the need to evaluate a string as an XPath.