<p>Hi,</p>
<p> </p>
<p>I have an XML file which needs to be used to generate the report. Due to complicated structure of the input XML file, I am using <strong>Scripted Data Source</strong>. Now in <strong>Scripted Dataset</strong>, I need to open the XML file at the <strong>open</strong><strong>(</strong><strong>)</strong> method of the DataSet. I used the following to open the XML file and access the same:</p>
<pre class="_prettyXprint _lang-js _linenums:1">
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
myFunction(xhttp);
}
}
xhttp.open("GET", "XML Files/books.xml", true);
xhttp.send();
function myFunction(xml){
var xmlDoc = xml.responseXML;
var x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
var txt=x.nodeValue;
count=2;
}
</pre>
<p>now in the <strong>fetch</strong><strong>(</strong><strong>)</strong> method of Scripted DataSet I have assigned the values of txt to a row. When I try to run the report, I'm getting an error as </p>
<div> </div>
<div><span>org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "varxhttp = new XMLHttpRequest(); .....</span></div>
<div> </div>
<div>":</div>
<p><span>Fail to execute script in function __bm_OPEN(). Source:</span></p>
<p><span>
<br>
" + varxhttp = new XMLHttpRequest();</span></p>
<p> </p>
<p>A BIRT exception occurred. See next exception for more information.</p>
<p><span>ReferenceError: "XMLHttpRequest" is not defined. (/report/data-sets/script-data-set[
@id="5"]/method[
@name="open"]#1).</span></p>
<p> </p>
<p>So my question is:</p>
<p>1) Can we open an XML using Javascript in the Dataset methods?</p>
<p>2)If not possible, can we call an external .js in the Dataset methods?</p>
<p>3)Can & how can we access/use report parameter in javascript (Syntax) of th dataset methods?</p>
<p>4)Is there any other workaround to get the XML file in Javascript?</p>
<p> </p>