Reputation: 59
I am currently working on an application that takes two xml files and compares them with XSLT 2.0 called from Javascript.
I am passing in parameters to the XSLT from my javascript like so:
xsltProcessor.setParameter(null, "testParameter", "I AM A TEST PARAMETER HEAR ME ROAR");
xsltProcessor.setParameter(null, "InputDirectory", "file:///D:/WORKSPACE/results_comparison_1.1/testng-results.xml");
And I am able to display these in the XSLT like so:
<xsl:value-of select="$testParameter" />
<xsl:value-of select="$InputDirectory"/>
Which gives me this output when I load the file up in my browser:
I AM A TEST PARAMETER HEAR ME ROARfile:///D:/WORKSPACE/results_comparison_1.1/testng-results.xml
All fine so far.
My problem:
The trouble is that I have a hardcoded variable like this, which I want to be assigned by an external parameter:
<xsl:variable name="reportFile" select="document('file:///D:/WORKSPACE/results_comparison_1.1/testng-results.xml')" />
I have tried something like:
<xsl:variable name="reportFile" select="document('$InputDirectory')" />
When InputDirectory corresponds to the parameter above. But it does not seem to work. Furthermore when I try to print it using something like this:
<xsl:value-of select="$reportFile" />
I get no error at all when I would usually get a long complicated error message showing up on the screen, which would seem to imply to me the "types" are different.
I was wondering how exactly I can get an xml file from external parameters in this way? Thanks very much.
Upvotes: 1
Views: 624
Reputation: 101680
It sure looks like the issue is here:
<xsl:variable name="reportFile" select="document('$InputDirectory')" />
This is telling it to load a document called "$InputDirectory". Instead, do this:
<xsl:variable name="reportFile" select="document($InputDirectory)" />
Upvotes: 1