JavaScript improvements with Rational Publishing Engine 2.1.1

JavaScript is one of the key components while building a Rational Publishing Engine (RPE) template. The plain JavaScript dialog editor has been improved with:

  • Content Assist: Ctrl + space lists available variables, helps with syntax of various JavaScript functions, parameters to be passed to a function. Tip: If the variable is a data attribute from a query, store it in a JavaScript variable to take advantage of content assist.
  • Syntax coloring: For any programming language, syntax coloring is a must.
  • Line marking: The line containing the cursor has a line marking.

Find more at https://jazz.net/blog/index.php/2017/01/17/javascript-improvements-with-rational-publishing-engine-2-1-1/

Understanding type of the model from DM

While building a cross product template from DNG to Design manager, the derived by attribute links to model diagram from Design Manager. How do you know whether it is a use case diagram or sequence diagram or something else?

If you make a GET request to DM model OSLC  / permanent URL (https://server:9443/dm/models/_Eea40KY8EeWtTLergOJe7g~OLDID__6018453__1) with Accept header as application/rdf+xml, you get OSLC representation of the resource. Looking at RDF/Description/type@resource attribute mentions whether the model is a use case or sequence diagram or etc. Continue reading “Understanding type of the model from DM”

Share variable across templates

There might be a scenario where you want to share a variable value across templates within a document specification. This is not supported directly using RPE template variable. However this could be achieved using Java system variable.

Note: Once the Java system variable is set, the variable value is available during future document generation until RPE Launcher / Studio is restarted. Hence, make sure to reset such variable value at the beginning of the template to avoid unnecessary results.

During concurrent document generation, if same variable name is used, it could result in inconsistent value. Hence, create a very unique variable name for using across document specifications. You could log (using _sessionLogger) the variable value before using them for printing. Continue reading “Share variable across templates”

New in RPE 2.1: ReUse JavaScript functions in template

RPE 2.1 allows the template designer to define JavaScript libraries/functions within the RPE template. The functions defined in those libraries are visible in all the other elements within the same template.

javascript-reuse

To mark a JavaScript element as a library, enable “Library script” property. Once enabled, the element name changes to “JavaScript Library“. The functions defined in such JavaScript library is available to all other elements within the template.

Watch the video on JavaScript reuse  in RPE template, created by my colleague Subramanya Prasad.

Continue reading “New in RPE 2.1: ReUse JavaScript functions in template”

Best Practices for building RPE Template – Part 1

It is important to build RPE template by following standard guidelines so that it would help greatly in maintaining the template for longer time. I’ll not target any specific data source here. These are general guidelines that could be followed while building or updating RPE template.

BC2

General Guidelines

  • Have separate templates for title, contents, end game so that some of them could be reused across document specifications. Include multiple templates in a single document specification (dsx) for document generation.
    • Whenever possible, use style sheet (word template) for title page instead of building it within RPE template. You could use the style sheet for Word and PDF output formats in document specification.
  • Keep templates small so that it can be managed easily for longer time.
  • Use notes (text) file to store various examples URLs. These will act as quick help while looking for data source and schema URLs. The same goes for JavaScript codes.

Part 2 – Template creation guidelines

 

Using JavaScript Objects/Arrays during iteration

When a JavaScript Array is populated with attributes within query on a container, you will notice that the Array object holds data for future iterations of the query while in the current iteration. This is because of how RPE processes the data and write to the output document in separate threads.

The solution here is to use additional variable called _arrayLength, which should be incremented for every query iteration and any operation on the Array should be through _arrayLength RPE variable.

js-array-iteration

Continue reading “Using JavaScript Objects/Arrays during iteration”

A node.js service for running Word Macros remotely

Word macros allow document creators to correct document  errors and fine tune the document formatting. Running the macros programatically through Word automation allows to automate the process for added benefits. There are a number of tools and processes that do this with  RPE being one of them.

Running macros is limited to the Windows platform  and it’s subject to additional limitations such as Word automation not being supported from NT Services ( as it’s the case for running RPE/RRDG running in WAS or Tomcat in Service mode).

To enable macros to run in situations where Word or Word automation is not available the solution is to execute the macros remotely by a dedicated service. Microsoft offers such a service in the form of Word Automation Services. Another solution, the one described in this article, is to a service that runs the macros through Word automation. The caveat of this service is that it cannot run as an NT service, it must run in an interactive desktop ( Apache Tomcat in console mode or node.js).

DISCLAIMER: The solution described in this article is provided as-is without warranty of any kind, express or implied. The service is not part of RPE and it is not supported by IBM.

Continue reading “A node.js service for running Word Macros remotely”