File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes passing a parameter to xsl from javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "passing a parameter to xsl from javascript" Watch "passing a parameter to xsl from javascript" New topic

passing a parameter to xsl from javascript

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

I am using Javascript to transform xml using xsl. I am passing a parameter to the xsl from javascript.

Here is the script:

var xslname = "L401_View.xsl" ;
var xslt;
var xslDoc;
var xmlDoc;
var action = "Annuity" ;

xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0") ;

xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");

xslDoc.async = false;
if (xslDoc.parseError.errorCode != 0)
var myErr = xslDoc.parseError;
alert ("You have error " + myErr.reason);
xslt.stylesheet = xslDoc ;
xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0") ;
xmlDoc.async = false ;
xmlDoc.load('<%=xml.toString(responseXML).replaceAll("\\s\\s+|\\n|\\r", "")%>') ;
if (xmlDoc.parseError.errorCode != 0)
var myErr = xmlDoc.parseError ;
alert ("You have error " + myErr.reason) ;

xslProc = xslt.createProcessor() ;
xslProc.input = xmlDoc ;
xslProc.addParameter("insuranceProduct", action) ;
xslProc.transform() ;
document.write(xslProc.output) ;

Here, responseXML is the xml generated by the jsp which has this script.
I am getting an error: "Access is denied" at the line:
xslt.stylesheet = xslDoc ;

There is no error while parsing the XSL. Can anybody tell me why am I getting this error?

Thanks and regards,
Amit Sanghai.
I agree. Here's the link:
subject: passing a parameter to xsl from javascript
It's not a secret anymore!