Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Binding with Scripted Data Set
sriram nagappan
<p>Hi Team,<br><br>
I have designed a report which entirely uses Document Object Model (DOM). The objective of the report is to display the Documents for the customer and along with few more fields like Amount,Currency,Expiry Date which are stored as User Defined Feilds (UDF). The structure is that a Customer can have many documents and each document will have these UDF's Amount,Currency,Expiry Date, etc. In XML file, there can be many Document Tag under REX tag and under each Document Tag, there can be many UDF inner tags.<br><br>
I have attached sample DOM dataset details (xml file) and the rptdesign file. In the report, i have used dataset 'Obligor' to fetch the Documents imported for the customer using Open & Fetch script.<br><br>
The issue here is that i am able to list all the documents of the customer but not able to fetch the User Defined Fields which are inner tags of the Document Tag. Can you please help on this.
Find more posts tagged with
Comments
Clement Wong
<p>The solution is attached. I used <a data-ipb='nomediaparse' href='
https://developer.mozilla.org/en-US/docs/Archive/Web/E4X/Processing_XML_with_E4X'>E4X
</a>(read my <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1122-parsing-xml-in-birt-with-e4x/'>DevShare
post</a> regarding its usage and a sample) to easily parse the XML using a Scripted Data Source / Data Set. The <em>beforeOpen</em>, <em>open </em>and <em>fetch </em>events have been overwritten.</p>
<p> </p>
<p>The logic to parse the data is in the <em>fetch</em></p>
<pre class="_prettyXprint">
//FOR DEBUG, THIS WORKS ONLY IN COMMERCIAL BIRT
//logger = java.util.logging.Logger.getLogger("birt.report.logger");
//logger.warning (result);
if( currentrow >= totalItems ){
return false;
}
row["OBJECT_NAME"] = rex.DOCUMENT[currentrow].
@OBJECT_NAME
;
row["Document ID"] = "unknown";
row["Document Type"] = rex.DOCUMENT[currentrow].
@ACA_AD_DOCTY
;
row["Document Status"] = rex.DOCUMENT[currentrow].
@ACA_AD_CCLCST
;
// Loop through the UDFs
for each(var udf in rex.DOCUMENT[currentrow].child('UDF'))
{
if (udf.
@UDTYNA
== "Expiry Date")
row["Expiry Date"] = java.text.SimpleDateFormat("yyyy-mm-dd").parse(udf.
@UDDA)
;
else if (udf.
@UDTYNA
== "Amount")
row["Amount"] = java.lang.Float.parseFloat(udf.
@UDDA
.toString());
else if (udf.
@UDTYNA
== "Checker")
row["Checker"] = udf.
@UDDA
;
}
currentrow++;
return true;</pre>
<p>Make sure to modify the file location in the <em>beforeOpen</em>.</p>
<p> </p>
<p>I've also addressed your other question in <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/37773-dom-datasource-how-to-sum-the-column-values/'>this
thread </a>about adding a total of the amount at the bottom. It was just as simple as inserting an aggregation report item as I previously suggested.</p>
sriram nagappan
<p>Hi Wong,</p>
<p> </p>
<p>Thanks a lot for your help. I am trying your solution and will let you know the result</p>
sriram nagappan
<p>Hi Wong,</p>
<p> </p>
<p>I have tried the solution with just modifying the fileReader variable as shown below, since the DOM is dynamic and it is generated by our Application.</p>
<p>"fileReader = client.getDomObject("Entity", ["RIENSHNA",inputParams["RIENSHNA"]], "MainData,+Attached.Documents");"</p>
<p> </p>
<p><span style="color:#ff0000;"><strong>Got the below error on generation.</strong></span></p>
<p> </p>
<p><strong><span style="color:#ff0000;">There are errors evaluating script "importPackage(Packages.java.io);<br>
importPackage(Packages.java.net);<br><br>
fileReader = client.getDomObject("Entity", ["RIENSHNA",inputParams["RIENSHNA"]], "MainData,+Attached.Documents");<br>
var bufferedReader = new BufferedReader(fileReader);<br>
var line;<br>
var result = "";<br>
while ((line = bufferedReader.readLine()) != null)<br>
result += line;<br>
bufferedReader.close();<br><br><br>
//FOR DEBUG, THIS WORKS ONLY IN COMMERCIAL BIRT<br>
//logger = java.util.logging.Logger.getLogger("birt.report.logger");<br>
//logger.warning (result);<br><br>
//Remove the first line <?xml version="1.0" ?>" to make it well formed XML<br>
result = result.replace(/<\?[^>]*>/g,""); <br>
//logger.warning (result);<br><br>
rex = new XML(result);<br>
totalItems = rex.DOCUMENT.length();":<br>
{1}. Error.ScriptEvaluationError ( 1 time(s) )<br>
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "importPackage(Packages.java.io);<br>
importPackage(Packages.java.net);<br><br>
fileReader = client.getDomObject("Entity", ["RIENSHNA",inputParams["RIENSHNA"]], "MainData,+Attached.Documents");<br>
var bufferedReader = new BufferedReader(fileReader);<br>
var line;<br>
var result = "";<br>
while ((line = bufferedReader.readLine()) != null)<br>
result += line;<br>
bufferedReader.close();<br><br><br>
//FOR DEBUG, THIS WORKS ONLY IN COMMERCIAL BIRT<br>
//logger = java.util.logging.Logger.getLogger("birt.report.logger");<br>
//logger.warning (result);<br><br>
//Remove the first line <?xml version="1.0" ?>" to make it well formed XML<br>
result = result.replace(/<\?[^>]*>/g,"");<br>
//logger.warning (result);<br><br>
rex = new XML(result);<br>
totalItems = rex.DOCUMENT.length();":<br>
{1}.<br>
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:96)<br>
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:219)<br>
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleBeforeOpen(DataSetScriptExecutor.java:85)<br>
at org.eclipse.birt.data.engine.impl.DataSetRuntime.beforeOpen(DataSetRuntime.java:538)<br>
at org.eclipse.birt.data.engine.impl.QueryExecutor.dataSetBeforeOpen(QueryExecutor.java:208)<br>
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:319)<br>
at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:448)<br>
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.produceQueryResults(PreparedDataSourceQuery.java:190)<br>
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:178)<br>
at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:560)<br>
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:152)<br>
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:265)<br>
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1875)<br>
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)<br>
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)<br>
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)<br>
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)<br>
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)<br>
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:170)<br>
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)<br>
at com.algorithmics.aclm.service.rendition.birt.BirtProcessor.render(BirtProcessor.java:158)<br>
at com.algorithmics.aclm.service.rendition.renderer.DocumentRenderer.doRender(DocumentRenderer.java:109)<br>
at com.algorithmics.aclm.service.rendition.renderer.DocumentRenderer.render(DocumentRenderer.java:65)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.doRun(RenditionEngine.java:122)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.access$100(RenditionEngine.java:95)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask$1.call(RenditionEngine.java:107)<br>
at com.algorithmics.vie.common.util.MeasuredCall.run(MeasuredCall.java:41)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.execute(RenditionEngine.java:104)<br>
at com.algorithmics.bps.engine.core.BaseEngine$EngineTask.call(BaseEngine.java:275)<br>
at com.algorithmics.bps.engine.core.BaseEngine.callSynchronous(BaseEngine.java:191)<br>
at com.algorithmics.bps.engine.core.BaseEngine.invoke(BaseEngine.java:180)<br>
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)<br>
at java.lang.reflect.Method.invoke(Method.java:620)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.invoke(LmRpcHandler.java:295)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.execute(LmRpcHandler.java:262)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.doHandleRequest(LmRpcHandler.java:178)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.handleRequest(LmRpcHandler.java:105)<br>
at com.algorithmics.ricos.env.rpc.LmRpcServer.handleRequest(LmRpcServer.java:99)<br>
at com.algorithmics.ricos.env.rpc.server.handler.rpc.RpcServerHandler.handleRpcRequest(RpcServerHandler.java:103)<br>
at com.algorithmics.ricos.env.rpc.server.handler.rpc.RpcServerHandler.handleRpcRequest(RpcServerHandler.java:68)<br>
at com.algorithmics.ricos.env.rpc.server.netty.RpcWorkerHandler.channelRead0(RpcWorkerHandler.java:49)<br>
at com.algorithmics.ricos.env.rpc.server.netty.RpcWorkerHandler.channelRead0(RpcWorkerHandler.java:32)<br>
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103)<br>
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:341)<br>
at io.netty.channel.DefaultChannelHandlerContext.access$700(DefaultChannelHandlerContext.java:30)<br>
at io.netty.channel.DefaultChannelHandlerContext$8.run(DefaultChannelHandlerContext.java:332)<br>
at com.algorithmics.ricos.env.rpc.server.netty.concurrent.NettyEventExecutor.run(NettyEventExecutor.java:25)<br>
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)<br>
at java.lang.Thread.run(Thread.java:809)<br>
Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: Java constructor for "java.io.BufferedReader" with arguments "org.apache.xerces.dom.DeferredDocumentImpl" not found. (#5)<br>
Script source: , line: 0, text:<br>
__bm_beforeOpen(). See next exception for more information.<br>
Error evaluating Javascript expression. Script engine error: Java constructor for "java.io.BufferedReader" with arguments "org.apache.xerces.dom.DeferredDocumentImpl" not found. (#5)<br>
Script source: , line: 0, text:<br>
__bm_beforeOpen()<br>
at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:118)<br>
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:773)<br>
at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:76)<br>
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:90)<br>
... 52 more<br>
Caused by: org.eclipse.birt.core.exception.CoreException: Error evaluating Javascript expression. Script engine error: Java constructor for "java.io.BufferedReader" with arguments "org.apache.xerces.dom.DeferredDocumentImpl" not found. (#5)<br>
Script source: , line: 0, text:<br>
__bm_beforeOpen()<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.wrapRhinoException(JavascriptEvalUtil.java:299)<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:102)<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(JavascriptEvalUtil.java:134)<br>
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:769)<br>
... 54 more<br>
Caused by: org.mozilla.javascript.EvaluatorException: Java constructor for "java.io.BufferedReader" with arguments "org.apache.xerces.dom.DeferredDocumentImpl" not found. (#5)<br>
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)<br>
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:922)<br>
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:978)<br>
at org.mozilla.javascript.Context.reportRuntimeError2(Context.java:948)<br>
at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:188)<br>
at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2266)<br>
at org.mozilla.javascript.gen.c11536._c1(:5)<br>
at org.mozilla.javascript.gen.c11536.call()<br>
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)<br>
at org.mozilla.javascript.gen.c11537._c0()<br>
at org.mozilla.javascript.gen.c11537.call()<br>
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)<br>
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)<br>
at org.mozilla.javascript.gen.c11537.call()<br>
at org.mozilla.javascript.gen.c11537.exec()<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)<br>
... 56 more</span></strong><br>
</p>
Clement Wong
<p>Oh, I see now from the stack trace that your "client" is returning <em>org.apache.xerces.dom.DeferredDocumentImpl</em> so you are using Apache Xerces DOM.</p>
<p> </p>
<p>To retrieve the extra information you can loop through the UDFs in the <strong>fetch </strong>event like how I did it in my code, but using your DOM "client".</p>
<pre class="_prettyXprint">
for each(var udf in rex.DOCUMENT[currentrow].child('UDF'))
{
if (udf.
@UDTYNA
== "Expiry Date")
row["Expiry Date"] = java.text.SimpleDateFormat("yyyy-mm-dd").parse(udf.
@UDDA)
;
else if (udf.
@UDTYNA
== "Amount")
row["Amount"] = java.lang.Float.parseFloat(udf.
@UDDA
.toString());
else if (udf.
@UDTYNA
== "Checker")
row["Checker"] = udf.
@UDDA
;
}</pre>
<p>You can add the following using DOM syntax to your original design, but I don't have a way to test this:</p>
<pre class="_prettyXprint">
//x=nodeList.getElementsByTagName("UDF")
// Loop through the UDFs to get the extra info
//
udfs = nodeList.getElementsByTagName("UDF");
// I'm pretty sure for each will work here. Otherwise try it without the keyword each
// for (var udf in udfs) {
//
for each (var udf in udfs) {
if (udf.getAttribute("UDTYNA") == "Expiry Date")
row["Expiry Date"] = java.text.SimpleDateFormat("yyyy-mm-dd").parse(udf.getAttribute("UDDA"));
else if (udf.getAttribute("UDTYNA") == "Amount")
row["Amount"] = java.lang.Float.parseFloat(udf.getAttribute("UDDA"));
else if (udf.getAttribute("UDTYNA") == "Checker")
row["Checker"] = udf.getAttribute("UDDA");
}
</pre>
sriram nagappan
<p>Hi Wong,</p>
<p> </p>
<p>I have added the above piece of script in fetch. But still i am getting the same error. Can you please confirm if this issue is due to the DOM returning from my Application. I am not sure if i am doing correctly. Can you please help on this.</p>
Clement Wong
<p>The same error should not occur if you use your original design/code as a base. My design uses a BufferedReader/fileReader because you sent an XML file, and my parsing was using E4X. I didn't realize that you were using Apache Xerces DOM until the stack trace. Please disregard my previously attached design's code, except for the overall picture of how it's populating the data set.</p>
<p> </p>
<p>The logic to loop through the UDF tags and populate the columns works correctly if you ran my design. Sorry, I don't have a way to test your "client" DOM returned by your app. </p>
<p> </p>
<p>Add the logic above to your fetch in the 'Obligor' data set. You may want to output debug statements, or try to run the report in Debug mode to trace through the any errors.</p>
sriram nagappan
<p>Hi Wong,</p>
<p> </p>
<p>I have used my original code and included your loop for UDF's, but i am getting below error. Can you please help</p>
<p> </p>
<p>There are errors evaluating script "if (idx >= nodeList.getLength())<br>
return false ;<br>
row["OBJECT_NAME"] = nodeList.item(idx).getAttribute("OBJECT_NAME")<br>
row["Document Type"] = nodeList.item(idx).getAttribute("ACA_AD_DOCTY")<br>
row["Document Status"] = nodeList.item(idx).getAttribute("ACA_AD_CCLCST")<br>
//x=nodeList.getElementsByTagName("UDF")<br>
idx = idx + 1 ;<br>
udfs = nodeList.getElementsByTagName("UDF");<br><br>
// I'm pretty sure for each will work here. Otherwise try it without the keyword each<br>
// for (var udf in udfs) {<br>
//<br>
for each (var udf in udfs) {<br><br><br>
if (udf.getAttribute("UDTYNA") == "Expiry Date")<br>
row["Expiry Date"] = java.text.SimpleDateFormat("yyyy-mm-dd").parse(udf.getAttribute("UDDA"));<br>
else if (udf.getAttribute("UDTYNA") == "Amount")<br>
row["Amount"] = java.lang.Float.parseFloat(udf.getAttribute("UDDA")); <br>
else if (udf.getAttribute("UDTYNA") == "Checker")<br>
row["Checker"] = udf.getAttribute("UDDA"); <br>
}<br>
return true ;<br>
":<br>
{1}. Error.ScriptEvaluationError ( 1 time(s) )<br>
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script "if (idx >= nodeList.getLength())<br>
return false ;<br>
row["OBJECT_NAME"] = nodeList.item(idx).getAttribute("OBJECT_NAME")<br>
row["Document Type"] = nodeList.item(idx).getAttribute("ACA_AD_DOCTY")<br>
row["Document Status"] = nodeList.item(idx).getAttribute("ACA_AD_CCLCST")<br>
//x=nodeList.getElementsByTagName("UDF")<br>
idx = idx + 1 ;<br>
udfs = nodeList.getElementsByTagName("UDF");<br><br>
// I'm pretty sure for each will work here. Otherwise try it without the keyword each<br>
// for (var udf in udfs) {<br>
//<br>
for each (var udf in udfs) {<br><br><br>
if (udf.getAttribute("UDTYNA") == "Expiry Date")<br>
row["Expiry Date"] = java.text.SimpleDateFormat("yyyy-mm-dd").parse(udf.getAttribute("UDDA"));<br>
else if (udf.getAttribute("UDTYNA") == "Amount")<br>
row["Amount"] = java.lang.Float.parseFloat(udf.getAttribute("UDDA"));<br>
else if (udf.getAttribute("UDTYNA") == "Checker")<br>
row["Checker"] = udf.getAttribute("UDDA");<br>
}<br>
return true ;<br>
":<br>
{1}.<br>
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:96)<br>
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.handleJS(DataSetScriptExecutor.java:219)<br>
at org.eclipse.birt.report.engine.script.internal.ScriptDataSetScriptExecutor.handleFetch(ScriptDataSetScriptExecutor.java:130)<br>
at org.eclipse.birt.data.engine.impl.ScriptDataSetRuntime.fetch(ScriptDataSetRuntime.java:103)<br>
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor$CustomDataSet.fetch(PreparedScriptDSQuery.java:257)<br>
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetchFromDataSet(DataSetToCache.java:238)<br>
at org.eclipse.birt.data.engine.executor.dscache.DataSetToCache.fetch(DataSetToCache.java:167)<br>
at org.eclipse.birt.data.engine.executor.cache.OdiAdapter.fetch(OdiAdapter.java:157)<br>
at org.eclipse.birt.data.engine.executor.cache.RowResultSet.next(RowResultSet.java:105)<br>
at org.eclipse.birt.data.engine.executor.cache.ExpandableRowResultSet.next(ExpandableRowResultSet.java:63)<br>
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.populateData(SmartCacheHelper.java:311)<br>
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.initInstance(SmartCacheHelper.java:283)<br>
at org.eclipse.birt.data.engine.executor.cache.SmartCacheHelper.getResultSetCache(SmartCacheHelper.java:244)<br>
at org.eclipse.birt.data.engine.executor.cache.SmartCache.<init>(SmartCache.java:69)<br>
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.populateOdiResultSet(PassUtil.java:132)<br>
at org.eclipse.birt.data.engine.executor.transform.pass.PassUtil.pass(PassUtil.java:62)<br>
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.doSinglePass(PassManager.java:183)<br>
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.pass(PassManager.java:93)<br>
at org.eclipse.birt.data.engine.executor.transform.pass.PassManager.populateResultSet(PassManager.java:74)<br>
at org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator.populateResultSet(ResultSetPopulator.java:196)<br>
at org.eclipse.birt.data.engine.executor.transform.CachedResultSet.<init>(CachedResultSet.java:135)<br>
at org.eclipse.birt.data.engine.executor.CandidateQuery.execute(CandidateQuery.java:111)<br>
at org.eclipse.birt.data.engine.impl.PreparedScriptDSQuery$ScriptDSQueryExecutor.executeOdiQuery(PreparedScriptDSQuery.java:223)<br>
at org.eclipse.birt.data.engine.impl.QueryExecutor.execute(QueryExecutor.java:1045)<br>
at org.eclipse.birt.data.engine.impl.ServiceForQueryResults.executeQuery(ServiceForQueryResults.java:232)<br>
at org.eclipse.birt.data.engine.impl.QueryResults.getResultIterator(QueryResults.java:158)<br>
at org.eclipse.birt.report.engine.data.dte.QueryResultSet.<init>(QueryResultSet.java:98)<br>
at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:168)<br>
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:265)<br>
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1875)<br>
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:80)<br>
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)<br>
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)<br>
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)<br>
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90)<br>
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)<br>
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:170)<br>
at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)<br>
at com.algorithmics.aclm.service.rendition.birt.BirtProcessor.render(BirtProcessor.java:158)<br>
at com.algorithmics.aclm.service.rendition.renderer.DocumentRenderer.doRender(DocumentRenderer.java:109)<br>
at com.algorithmics.aclm.service.rendition.renderer.DocumentRenderer.render(DocumentRenderer.java:65)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.doRun(RenditionEngine.java:122)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.access$100(RenditionEngine.java:95)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask$1.call(RenditionEngine.java:107)<br>
at com.algorithmics.vie.common.util.MeasuredCall.run(MeasuredCall.java:41)<br>
at com.algorithmics.aclm.service.rendition.RenditionEngine$RenditionTask.execute(RenditionEngine.java:104)<br>
at com.algorithmics.bps.engine.core.BaseEngine$EngineTask.call(BaseEngine.java:275)<br>
at com.algorithmics.bps.engine.core.BaseEngine.callSynchronous(BaseEngine.java:191)<br>
at com.algorithmics.bps.engine.core.BaseEngine.invoke(BaseEngine.java:180)<br>
at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)<br>
at java.lang.reflect.Method.invoke(Method.java:620)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.invoke(LmRpcHandler.java:295)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.execute(LmRpcHandler.java:262)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.doHandleRequest(LmRpcHandler.java:178)<br>
at com.algorithmics.ricos.env.rpc.marshal.LmRpcHandler.handleRequest(LmRpcHandler.java:105)<br>
at com.algorithmics.ricos.env.rpc.LmRpcServer.handleRequest(LmRpcServer.java:99)<br>
at com.algorithmics.ricos.env.rpc.server.handler.rpc.RpcServerHandler.handleRpcRequest(RpcServerHandler.java:103)<br>
at com.algorithmics.ricos.env.rpc.server.handler.rpc.RpcServerHandler.handleRpcRequest(RpcServerHandler.java:68)<br>
at com.algorithmics.ricos.env.rpc.server.netty.RpcWorkerHandler.channelRead0(RpcWorkerHandler.java:49)<br>
at com.algorithmics.ricos.env.rpc.server.netty.RpcWorkerHandler.channelRead0(RpcWorkerHandler.java:32)<br>
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103)<br>
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:341)<br>
at io.netty.channel.DefaultChannelHandlerContext.access$700(DefaultChannelHandlerContext.java:30)<br>
at io.netty.channel.DefaultChannelHandlerContext$8.run(DefaultChannelHandlerContext.java:332)<br>
at com.algorithmics.ricos.env.rpc.server.netty.concurrent.NettyEventExecutor.run(NettyEventExecutor.java:25)<br>
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)<br>
at java.lang.Thread.run(Thread.java:809)<br><strong>Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: TypeError: Cannot find function getElementsByTagName in object org.apache.xml.dtm.ref.DTMNodeList@829e4e6. (#8)<br>
Script source: , line: 0, text:<br>
__bm_FETCH(). See next exception for more information.<br>
Error evaluating Javascript expression. Script engine error: TypeError: Cannot find function getElementsByTagName in object org.apache.xml.dtm.ref.DTMNodeList@829e4e6. (#8)<br>
Script source: , line: 0, text:<br>
__bm_FETCH()</strong><br>
at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:118)<br>
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:773)<br>
at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethodRunner.java:76)<br>
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.handleJS(DtEScriptExecutor.java:90)<br>
... 69 more<br>
Caused by: org.eclipse.birt.core.exception.CoreException: Error evaluating Javascript expression. Script engine error: TypeError: Cannot find function getElementsByTagName in object org.apache.xml.dtm.ref.DTMNodeList@829e4e6. (#8)<br>
Script source: , line: 0, text:<br>
__bm_FETCH()<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.wrapRhinoException(JavascriptEvalUtil.java:299)<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:102)<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(JavascriptEvalUtil.java:134)<br>
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:769)<br>
... 71 more<br>
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function getElementsByTagName in object org.apache.xml.dtm.ref.DTMNodeList@829e4e6. (#8)<br>
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)<br>
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)<br>
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)<br>
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)<br>
at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3646)<br>
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2186)<br>
at org.mozilla.javascript.gen.c24616._c1(:8)<br>
at org.mozilla.javascript.gen.c24616.call()<br>
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)<br>
at org.mozilla.javascript.gen.c60._c0()<br>
at org.mozilla.javascript.gen.c60.call()<br>
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)<br>
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)<br>
at org.mozilla.javascript.gen.c60.call()<br>
at org.mozilla.javascript.gen.c60.exec()<br>
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)<br>
... 73 more</p>
Clement Wong
<p>Sorry, but I have no way of testing your custom code to loop through the UDFs. To mimic my example, you will need to a find a method for your custom class that can cycle through the each <UDF> and look for the attributes you need.</p>
<p> </p>
<p> </p>
<p>Regards,</p>
<p>Clement</p>
sriram nagappan
<p>Hi Wong,</p>
<p> </p>
<p>I need a basic clarification on how to Parse a dynamic value in XPath. Below is the XPath, i normally use with a direct value</p>
<p> </p>
<p>XPATH("/REX/<span style="color:#ff0000;"><strong>DOCUMENT[
@OBJECT_NAME=
'TEST DOCUMENT']/</strong></span>UDF"</p>
<p> </p>
<p>But in above BIRT report, i need to pass OBJECT_NAME dynamically like below. Please confirm if this will work.</p>
<p>nodeList1 = client.xpath(domData, "/REX/<span style="color:#ff0000;"><strong>DOCUMENT[
@OBJECT_NAME=nodeList
.item(idx).getAttribute("OBJECT_NAME")]</strong></span>/UDF", XPathConstants.NODESET) ;</p>
<p> </p>
<p>Also, Please confirm if this script will work in Fetch script, because i can't use this script in Open, since OBJECT_NAME is dynamic.</p>
Clement Wong
<p>Again, sorry, but I do not have a way of testing your custom code in my environment.</p>
<p> </p>
<p>Based on the XML returned, you should be able to build the XPath and extract the various attributes in the UDF tags. If I was able to parse it using my technique in the sample I sent previously, you should be able to do the same with XPath.</p>