Analytics Publisher Code for Policy Modeling

This topic shows the format that is required for the following elements when using Analytics Publisher with Policy Modeling to develop an RTF form template:

(The Analytics Publisher code for PDF form templates is available in the PDF Form Assistant. For more information, see Design a PDF Template for a Form.)

Further information on Analytics Publisher code is available in Designing and Publishing Pixel-Perfect Reports in Oracle Analytics Server.

Values and properties of global attributes

The table below shows the Analytics Publisher format (defined as Code in the Advanced tab) needed for the fields to display various values and properties of global attributes.

Table 1. The Analytics Publisher format for displaying global attributes
To display Analytics Publisher format Example Output Notes
Attribute value (formatted) <?attribute_name_value?> <?assessment_date_value?> 3/06/11 Formatted for the region specified in the Policy Modeling project (in this example, Australia). Formatted attribute value fields do not need the default Analytics Publisher code modified. These fields can simply be dragged and dropped into your template from the Field dialog box and require no further modification.
Attribute text <?attribute_name_text?> <?improvements_text?> There are improvements that the customer could make to the children's diet. Attribute text fields do not need the default Analytics Publisher code modified. These fields can simply be dragged and dropped into your template from the Field dialog box and require no further modification.
Attribute value (unformatted) <?attribute_name/value?> <?assessment_date/value?> 2011-06-03 Analytics Publisher provides a range of functions for working with unformatted data, including date settings. To use Analytics Publisher's formatting features, select the Type and Format that you want for the value in the Properties tab for the field.
Attribute question text <?attribute_name/@question?> <?improvements/@question?> Are there improvements that the customer could make to the children's diet?  
Attribute type <?attribute_name/@type?> <?improvements/@type?> Boolean This will return the attribute type (that is, Boolean, text, currency, number, date, date and time, time of day).
Inferred status <?attribute_name/@inferred?> <?improvements/@inferred?> true This indicates whether the attribute is inferred (that is, true) or not (that is, false).

Values and properties of entity-level attributes

The table below shows the Analytics Publisher format needed to display entity-level attributes in various layouts. Each element enclosed in brackets (<>) is a separate Analytics Publisher field. Each of these fields must have the specified code set in the Advanced tab for the field. <entity_level_attribute_element> is a field that takes the same format as those used to display global attributes (see above) but using entity-level attribute values and properties instead.

Table 2. The Analytics Publisher format for displaying entity-level attributes
To display Analytics Publisher format Example Output Notes
Entity-level attributes grouped by entity
<?for-each:list-entity_name/entity_name?>
<entity_level_attribute_element>
<entity_level_attribute_element>
<entity_level_attribute_element> ...
<?end for-each?>
<?for-each:list-child/child?>
<?child_name_text?>
<?child_rating_overall_text?>
<?child_rating_overall/@question?>  <?child_rating_overall_value?>
<?end for-each?>

The child is Hayden.

Hayden's overall star rating is 4.

What is Hayden's overall star rating? 4

The child is Courtney.

Courtney's overall star rating is 2.

What is Courtney's overall star rating? 2

This format is also used when displaying entity level attributes in a native Microsoft Word table. That is, the first cell in the row needs to start with the <?for-each:entity_name?> field, and the last cell in the same row needs to end with the <?end for-each?> field (with the entity-level attribute fields in between).
Entity-level attributes grouped by attribute
<?for-each:list-entity_name/entity_name?><entity_level_attribute_element><?end for-each?>
<?for-each:entity_name?><entity_level_attribute_element><?end for-each?>
<?for-each:entity_name?><entity_level_attribute_element><?end for-each?> ...
<?for-each:list-child/child?><?child_name_text?><?end for-each?>
<?for-each:child?><?child_rating_overall_text?><?end for-each?>
<?for-each:child?><?child_rating_overall/@question?> <?child_rating_overall_value?><?end for-each?>

The child is Hayden.

The child is Courtney.

Hayden's overall star rating is 4.

Courtney's overall star rating is 2.

What is Hayden's overall star rating? 4

What is Courtney's overall star rating? 2

 
Entity-level attributes sorted alphabetically by entity name
<?for-each:list-entity_name/entity_name?>
<?sort:entity_name_id_value;'ascending';data-type='text'?>
<entity_level_attribute_element>
<entity_level_attribute_element>
<entity_level_attribute_element> ...
<?end for-each?>
<?for-each:list-child/child?><?sort:child_name_value;'ascending';data-type='text'?> <?child_name_value?>:  
<?child_servings_sweets_text?> 
<?child_servings_fruit_text?> 
<?child_servings_dairy_text?> <?end for-each?>

Courtney:

The number of servings of sweets Courtney eats per day is 5.

The number of servings of fruit Courtney eats per day is 2.

The number of servings of dairy food Courtney eats per day is 3.

Hayden:

The number of servings of sweets Hayden eats per day is 0.

The number of servings of fruit Hayden eats per day is 3.

The number of servings of dairy food Hayden eats per day is 2.

This format can be used in native Microsoft Word tables too. That is, the first cell in the row needs to start with the <?for-each:entity_name?><?sort:entity_name_id_value;'ascending';data-type='text'?> fields, and the last cell in the same row needs to end with the <?end for-each?> field (with the entity-level attribute fields in between).

Conditional text and formatting

The table below shows the Analytics Publisherformat needed to display conditional text or formatting. Each element enclosed in brackets (<>) is a separate Analytics Publisher field. Each of these fields must have the specified code set in the Advanced tab for the field. Display text is the text that you want to have shown when the specified condition is met.

Table 3. The Analytics Publisher format for displaying conditional text and formatting
To display Analytics Publisher format Example Notes
Text when a Boolean attribute has a particular value <?if:attribute_name/value='unformatted attribute value'?>Display text<?end if?> <?if:improvements/value='true'?>Please make an appointment with one of our friendly dieticians to discuss how you could improve your family's health.<?end if?> Displays the text "Please make an appointment with one of our friendly dieticians to discuss how you could improve your family's health" when the attribute "There are improvements that the customer could make to the children's diet" is true. No text is displayed if the attribute is false, uncertain, or unknown.
Text when a number attribute has a particular value <?if:number(attribute_name/value)>unformatted attribute value?>Display text<?end if?> <?if:number(cars_owned/value)>2?>As you have more than two cars, a double garage may not be suitable.<?end if?> This format/example uses the greater than operator (>) but any of the comparison operators can be used here.
Text when a currency attribute has a particular value <?if:number(attribute_name/value)<unformatted attribute value?>Display text<?end if?> <?if:number(total_reimbursement/value)<9?> You have been reimbursed less than the full amount.<?end if?> This format/example uses the less than operator (<) but any of the comparison operators can be used here.
Text when a date attribute has a particular value <?if:date(attribute_name/value)<date('unformatted attribute value')?>Display text<?end if?> <?if:date(date_of_birth/value)<date('2000-01-01')?>You were born last century.<?end if?> This format/example uses the less than operator (<) but any of the comparison operators can be used here.
Certain text when a formatted attribute has a particular value, otherwise displaying alternative text <?choose:?><?when:attribute_name_value='formatted attribute value'?>Display text when condition met<?end when?><?otherwise:?>Alternate display text<?end otherwise?><?end choose?> <?choose:?><?when:overall_rating_value='Excellent'?>Your children's diet is very well-balanced. Keep up the good work!<?end when?><?otherwise:?>There are improvements that you can make to your children's diets.<?end otherwise?><?end choose?>

Displays the text "Your children's diet is very well-balanced. Keep up the good work!" when the family's overall health assessment is Excellent. Otherwise displays the text "There are improvements that you can make to your children's diets."

This format/example uses equals (=) in the condition element but you can use other comparison operators, in which case, use the formatting described above.

Attribute value formatted a certain way when a formatted attribute has a particular value <?choose:?><?when:attribute_name_value>'formatted attribute value'?><?attribute_name_value?><?end when?><?otherwise:?> <?attribute_name_value?> <?end otherwise?><?end choose?> <?choose:?><?when:total_sweets_value>'4'?><?total_sweets_value?> <?end when?><?otherwise:?><?total_sweets_value?><?end otherwise?><?end choose?>

Displays the total number of sweets consumed by the children in bold red format if that number is greater than 4. Otherwise displays the total number of sweets consumed by the children in black non-bold format.

This can also be achieved by implementing conditional formatting. See the Analytics Publisher Users Guide for more information.

Explanations

To display an explanation you need to:

  • have the attribute selected in the list of explanation attributes available for the form, and
  • have a field (decision-report template) in your template which defines the structure and format of the explanation, and
  • have a field (call decision report template) in your template which specifies the attribute (attribute_name) to give the explanation on.

The table below specifies the Analytics Publisher code needed to define the two fields described above.

Table 4. The Analytics Publisher code used to display explanations
Field Analytics Publisher code Example Notes
decision-report template <?template@inlines:decision-report?> <?if@inlines:"attribute-node"?> <fo:list-block start-indent="{count(ancestor::attribute-node) * 7}mm"> <fo:list-item> <fo:list-item-label> <fo:block>*</fo:block> </fo:list-item-label> <fo:list-item-body> <fo:block><xsl:value-of select="@text"/></fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> <?for-each@inlines:./attribute-node?><?call-template:decision-report?><?end for-each?> <?end if?> <?end template?>

 

This field only needs to appear in a template document once.
call decision report template <?for-each:/global-instance/attribute_name/decision-report/*?><?call-template:decision-report?><?end for-each?> <?for-each:/global-instance/improvements/decision-report/*?><?call-template:decision-report?><?end for-each?>  

Signatures

To display a signature you need to:

  • have a signature control on a screen in the interview, and
  • have a signature_image_data field in your template which identifies the signature to use and advises Analytics Publisher to treat the data as an image (not a string).

The table below specifies the Analytics Publisher code needed to define signature fields for global and entity-level signatures.

Table 5. The Analytics Publisher code used to display signatures
Field Analytics Publisher code Example Notes
signature_image_data (global) <fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><?signature_image_data?></fo:instream-foreign-object> <fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><?signature_image_data?></fo:instream-foreign-object>  
signature_image_data (entity) <fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><?entity_name_signature_image_data?></fo:instream-foreign-object> <fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><?child_signature_image_data?></fo:instream-foreign-object> Entity-level signature fields need to be added within an entity group (that is, preceded by a For Each field, and followed by an End field).