B
bearclaws
I am trying to send URL parameters from an HTML page to an XSL page.
I used this script to pass parameters manually to the XSL and it works
great. I just modified the "input for XSL-processor" section:
http://www.biglist.com/lists/xsl-list/archives/200107/msg00002.html
However, I'd like to be able to build that parameter list dynamically.
So far, I can get the parameters into an array and pass the values to
the loadXML function; however, I cannot get the script to write the
list of parameters and send them to XSL.
I've included my two scripts below. getURLparameters() extracts the URL
parameters and loadXML() loads the XML/XLS pages.
Any thoughts?
Thanks,
BC
////////////////////////////////////
function getURLparameters() {
var parameterArray =
unescape(self.location.search).substring(1).split("&");
if (self.location.search.indexOf("=") == -1) {
loadXML(parameterArray)
return;
}
for (var i=0;i<parameterArray.length;i++) {
parameterArray = parameterArray.split("=");
}
loadXML(parameterArray);
}
////////////////////////////////////
function loadXML(parameterList) {
// Load your XSL
var objXSLT = new ActiveXObject("MSXML2.FreeThreadedDomDocument")
objXSLT.async = false
objXSLT.load("myxslpage.xsl")
// create a compiled XSL-object
var objCompiled = new ActiveXObject("MSXML2.XSLTemplate")
objCompiled.stylesheet = objXSLT.documentElement
// create XSL-processor
var objXSLProc = objCompiled.createProcessor()
// Load your XML
var objXML = new ActiveXObject("MSXML2.FreeThreadedDomDocument")
objXML.async = false
objXML.load("myxmlpage.xml")
// input for XSL-processor
objXSLProc.input = objXML
// build list of URL parameters and send to XSL
for (i = 0;i < parameterList.length;i++)
{
eval(objXSLProc.addParameter(parameterList[0],
parameterList[1]));
alert(parameterList[0] + " = \"" + parameterList[1] + "\";");
}
// transform
objXSLProc.transform()
// display
document.write(objXSLProc.output)
I used this script to pass parameters manually to the XSL and it works
great. I just modified the "input for XSL-processor" section:
http://www.biglist.com/lists/xsl-list/archives/200107/msg00002.html
However, I'd like to be able to build that parameter list dynamically.
So far, I can get the parameters into an array and pass the values to
the loadXML function; however, I cannot get the script to write the
list of parameters and send them to XSL.
I've included my two scripts below. getURLparameters() extracts the URL
parameters and loadXML() loads the XML/XLS pages.
Any thoughts?
Thanks,
BC
////////////////////////////////////
function getURLparameters() {
var parameterArray =
unescape(self.location.search).substring(1).split("&");
if (self.location.search.indexOf("=") == -1) {
loadXML(parameterArray)
return;
}
for (var i=0;i<parameterArray.length;i++) {
parameterArray = parameterArray.split("=");
}
loadXML(parameterArray);
}
////////////////////////////////////
function loadXML(parameterList) {
// Load your XSL
var objXSLT = new ActiveXObject("MSXML2.FreeThreadedDomDocument")
objXSLT.async = false
objXSLT.load("myxslpage.xsl")
// create a compiled XSL-object
var objCompiled = new ActiveXObject("MSXML2.XSLTemplate")
objCompiled.stylesheet = objXSLT.documentElement
// create XSL-processor
var objXSLProc = objCompiled.createProcessor()
// Load your XML
var objXML = new ActiveXObject("MSXML2.FreeThreadedDomDocument")
objXML.async = false
objXML.load("myxmlpage.xml")
// input for XSL-processor
objXSLProc.input = objXML
// build list of URL parameters and send to XSL
for (i = 0;i < parameterList.length;i++)
{
eval(objXSLProc.addParameter(parameterList[0],
parameterList[1]));
alert(parameterList[0] + " = \"" + parameterList[1] + "\";");
}
// transform
objXSLProc.transform()
// display
document.write(objXSLProc.output)