1

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.

1 Answer 1

1

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)" />
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow I was messing around with that for ages, I can't believe it but that did it. Thanks a million for your answer JLRishe, I really appreciate it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.