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"/>
jmcoAsked:
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

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

param.xsl
=======
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="extParam" />
    <xsl:template match="/">
        <h1>
            <xsl:for-each select="//test">
                <xsl:value-of select="." /><xsl:value-of select="$extParam" />
            </xsl:for-each>
        </h1>
    </xsl:template>
</xsl:stylesheet>

and the JavaScript
============
<html>
<head>
<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
oXSLT.load("param.xsl");

//setting stylesheet property to the XSLT Tree
oTemplate.stylesheet = oXSLT;
oXML.load("param.xml");

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

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

//passing external values to a named parameter
oProc.addParameter("extParam",sParam);

window.onload = init;
function init() {
  //perform transformation
  oProc.transform();
  document.body.innerHTML = oProc.output;
}
</script>
</head>
<body></body>
</html>

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
COBOLdinosaurCommented:
That looks like it is IE only?

Cd&
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:
COBOLdinosaur,

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

cheers,
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:
Well,
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
XML

From novice to tech pro — start learning today.