This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
Author

passing a parameter to xsl from javascript

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
Hi,

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;
xslDoc.load(xslname);
if (xslDoc.parseError.errorCode != 0)
{
var myErr = xslDoc.parseError;
alert ("You have error " + myErr.reason);
}
else
{
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: http://aspose.com/file-tools
 
subject: passing a parameter to xsl from javascript
 
Similar Threads
XML string parsing in javascript
Doubt in Ajax
Ajax: ResponseXML is null
read and parse an external xml using javascript
Page section does not update after call of a4j:support in IE 9