Java example for LINQ Reporting Engine <<doc [doc_expression]>> needed

Can somebody give me a basic Java example of how to use the doc doc_expression tag as described here: Inserting Documents Dynamically in Java|Aspose.Words for Java

If I replace doc_expression with the name of a Document or InputStream object reference in the text of a doc template, how does it find the actual object instantiated in code? Does it use reflection or do I call some undiscovered method of ReportBuilder to identify it? The article has no explanation and I could not find any answers in the forums either. Thank you.

@rocketpower

LINQ Reporting Engine does not scan client code to find an instantiated object. It can access only objects passed to ReportingEngine.buildReport as data sources (with their specified names to be used in a template). So, to access an instantiated document instance or InputStream, one can pass it to the engine as a separate data source or as a member of another data source object. Here is sample code for the first option:

Document template = ...
Document docToInsert = ...
ReportingEngine engine = new ReportingEngine();
engine.buildReport(template, new Object[] { ..., docToInsert }, new String[] { ..., "docToInsert" });

A sample template might look like this then:

<<doc [docToInsert]>>

Note, the data source name may differ from the variable name in code, they are not connected in any way.

Thank you, that’s exactly what I needed. I might suggest that Document and InputStream objects be added to the bulleted list of acceptable objects in the API docs for ReportintEngine.buildReport() datasources above the line “Any other Java object” just for clarity since they act in a special way. Thanks again.

@rocketpower

Thanks for the highlight. We will consider possible improvements in documentation in this regard.