Accessing the docgen configuration information in JavaScript


RPE 1.2.1 introduced three new Internal Variables:

  • _sessionInfo
  • _sessionLogger
  • _sessionUtils

The _sessionLogger gives you access to the RPE Log system so that any debug/troubleshooting messages will reach the log file as well.

The _sessionUtils exposes utility functions for JavaScript. At the time of writing this ( RPE 1.2.1.1) _sessionUtils only exposes the tidyXHTML function.

Out of the 3 the most interesting is the _sessionInfo variable which gives access to the document generation configuration properties and more.

The _sessionInfo exposes 4 properties and 4 functions:

Properties

  1. _sessionInfo.docspecVersion  – the version of the document specification. Can only be 1.
  2. _sessionInfo.templateVersion – the version of the template. Can be 1 or 2.
  3. _sessionInfo.engineVersion – the version of the RRDG Engine running the docgen. Example: 1.2.1, 1.2.1.1 etc
  4. _sessionInfo.buildNumber – the build number of the RRDG Engine. This is useful to determine the exact patch level of RRDG. Example: 20140228_2104

Methods

1. _sessionInfo.getDocspecProperty( propertyName, defaultValue)
Returns the value of the document specification property with the specified name. Valid docspec properties are “path” and all the properties in the metadata section. If the property does not exist it returns the value provided in the defaultValue parameter.

Scope: document generation

Example:

  • _sessionInfo.getDocspecProperty( “missing data text”, “-“)
  • _sessionInfo.getDocspecProperty( “path”, “-“)

2. _sessionInfo.getTemplateProperty( propertyName, defaultValue)

Returns the value of the Template property with the specified name. If the property does not exist it returns the value provided in the defaultValue parameter.

Scope: current template

Example:

  • _sessionInfo.getTemplateProperty( “path”, “-“)

3. _sessionInfo.getDatasourceProperty( dsName, propertyName, defaultValue)

Returns the value of the data source’s <dsName> property with the specified name. If the data source with that name does not exist in the current template or the property does not exist the function returns the value provided in the defaultValue parameter.

Scope: current template

Example:

  •  _sessionInfo.getDatasourceProperty( “DS1”, “URI”, “-“)
  •  _sessionInfo.getDatasourceProperty( “DS1”, “type”, “-“)
  •  _sessionInfo.getDatasourceProperty( “DS1”, “username”, “-“)

NOTE: passwords are provided in their encrypted form as stored in the docspec.

4. _sessionInfo.getOutputProperty(  outputType, propertyName, defaultValue)

Returns the value of the <outputType> output property with the specified name. If the output is not found or the property does not exist it returns the value provided in the <defaultValue> parameter.

Scope: document generation

Example:

  • _sessionInfo.getOutputProperty( “Word”, “path”, “-“)
  • _sessionInfo.getOutputProperty( “Word”, “stylesheet”, “-“)

NOTE: if the path property of the output is empty RPE will return the empty string for the “path” property and not the internally generated name.

Advertisements

Author: Dragos Cojocari

Architect for Rational Publishing Engine

1 thought on “Accessing the docgen configuration information in JavaScript”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s