Use javascript to get URL parameters and send to XSL (problem)

Discussion in 'XML' started by bearclaws, Feb 4, 2005.

  1. bearclaws

    bearclaws Guest

    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)
     
    bearclaws, Feb 4, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon paugh
    Replies:
    1
    Views:
    954
  2. Ray Tayek
    Replies:
    3
    Views:
    539
    Ray Tayek
    Nov 30, 2003
  3. MC
    Replies:
    1
    Views:
    7,360
    David Carlisle
    Mar 24, 2005
  4. Replies:
    1
    Views:
    3,691
    A. Bolmarcich
    May 27, 2005
  5. Replies:
    0
    Views:
    560
Loading...

Share This Page