javascript variable to XSLT variable

I have been trying this almost all day now, Is this even possible?

<xsl:variable name="color" select="some js variable"/>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
If you use IE, you can use .addParameter
Gertone (Geert Bormans)Information ArchitectCommented:
Here is how you pass the JavaScript variable to an XSLT parameter

<?xml version="1.0" encoding="UTF-8"?>
<test>###Content### =</test>

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:param name="extParam" />
    <xsl:template match="/">
            <xsl:for-each select="//test">
                <xsl:value-of select="." /><xsl:value-of select="$extParam" />

and the JavaScript
<title>External Parameter Test</title>
<script language="javascript">
var sParam = " MY TEST PARAMETER";

//create XSLTemplate40
var oTemplate = new ActiveXObject("Msxml2.XSLTemplate.4.0");

//create DOMDocument40
var oXML = new ActiveXObject("Msxml2.DOMDocument.4.0");

//create FreeThreadedDOMDocument40
var oXSLT = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");

oXSLT.async = oXML.async = false;

//loading XSLT Document

//setting stylesheet property to the XSLT Tree
oTemplate.stylesheet = oXSLT;

//create IXSLProcessor
var oProc = oTemplate.createProcessor();

//set the input property to the XML Tree
oProc.input = oXML;

//passing external values to a named parameter

window.onload = init;
function init() {
  //perform transformation
  document.body.innerHTML = oProc.output;

Is that what you are looking for?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
That looks like it is IE only?

Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Gertone (Geert Bormans)Information ArchitectCommented:

yes it is IE only!
hence my warning / question in my first message

jmcoAuthor Commented:
Sort of but i am working with an xslt data view within sharepoint. I have a limited number of tags i can use. Is there anyway to do it directly on the variable declaration. For example i can convert from xslt to js. by doing
var sParam = '<xsl:value-of select="Name"/>

If there a simplier way to do the reverse?
Gertone (Geert Bormans)Information ArchitectCommented:
another approach you can take is
- load the StyleSheet in a DOM object
- select the parameter node
- overwrite the parameter node, with the value of the JS-variable
- run the process using the new template
Or is that still not dynamic enough?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.