To use Cognos product documentation, you must enable JavaScript in your browser.

Adding Custom Report Templates for Report Studio

Report Studio has predefined report templates that you select from when you create a new report. You can create your own custom report templates and make them available too.

To add a custom report template, you must

      

create a report specification for the template

      

add a custom report template to the templates.xml file

      

provide an icon for the template

      

add template information to the Resources.xml file

Note: When you reinstall or upgrade Cognos 8, the changes associated with the custom report templates are not migrated. You may need to redo the above steps .

Create a Report Specification for a Custom Report Template

There is no template object in Cognos 8. Instead, you can use any report specification as a report template. You can create the report specification for your custom report template by using Report Studio, an XML editor, or a text editor.

Steps for Report Studio
  1. Open Report Studio.

  2. Create a new report.

    For more information, see the Report Studio User Guide.

  3. From the File menu, click Convert to Template.

  4. From the Tools menu, click Copy Report to Clipboard to save the report specification XML.

  5. Paste the report specification into an XML editor or text editor.

  6. Delete the following information, which Report Studio adds to the XML file and which is not necessary for the template:

  7. Add a new template element as a parent of the report element.

  8. Add a name attribute for the template element.

    The name you enter appears as the name of the template in the new report dialog box.

  9. Save the report specification.

Here is an example of the initial part of a report specification created in Report Studio. The portions to delete appear in bold.

 <template name="CognosList"> 
   ...
   <report xmlns="http://developer.cognos.com/schemas/report/4.0/" 
expressionLocale="en" template="true"><!--RS:8.2-->
  <queries>
   <query name="Query1">
     <source>
        <model/>
     </source>
     <selection/>
   </query>
 </queries>
 <layouts>
   <layout>
    <reportPages>
      <page class="pg" name="Page1">
        <pageBody class="pb">
          <contents>
            <list class="ls" refQuery="Query1"> 
              <style>
                <CSS value="border-collapse:collapse"/>
              </style>
             </list>
               .................
   </report>
  </template>
Steps for an XML Editor or Text Editor
  1. Open the report specification in an XML editor or text editor.

  2. Add the elements you want to appear in your template.

    For more information, see the Developer Guide.

  3. Add a new template element as a parent of the report element.

    The name you enter appears as the name of the template in the new report dialog box.

  4. Add a name attribute to the template element.

    The name you enter appears as the name of the template in the new report dialog box.

  5. Save the report specification.

Add a Custom Report Template to the templates.xml File

The Templates.xml file contains the templates that you select from when you create a new report in Report Studio. You must add your custom report template to this file.

Steps
  1. Open the templates.xml file.

    This file is located in the c8_location/webcontent/pat/res directory.

  2. Copy the XML code for the custom report template into the file.

    The template element must be a child element of the xmlFragment element.

  3. Add the <modelPath/> directive.

    Here is an partial example of the XML for the template created in the previous task .

    <xmlFragment> template name="CognosList"> <report> <modelPath/> ... </template> </xmlFragment>

  4. Save and close the file.

Provide an Icon for the Custom Report Template

You can create an icon that you want to represent the custom report template. The icons in the new report dialog box are 32 x 32 pixels .gif images.

You can use any graphic editor to create the icon.

Steps
  1. Create the icon you want.

  2. Copy the image file into the c8_location/webcontent/pat/images directory.

Add Template Information to the Resources.xml File

The Resources.xml file defines the content of the new report dialog box in Report Studio. You must modify this file by adding the information that refers to the custom report template.

For the listItems element, you add a new listItem element that represents the new template. The listItem element must have the following attributes.

Attribute

Description

idsLabel

Specifies an ID that refers to a Report Studio string resource file located in the c8_location/webcontent/pat/res directory, and a label for the template that appears in the new report dialog box.

Use this attribute when you want to add the ID and label for your custom template in the string resource file. You use the string resource file when you want the label to appear in multiple languages.

label

Specifies a label for the template that appears in the new report dialog box.

Use this attribute instead of the idsLabel attribute for the custom template when you do not want the label to appear in multiple languages, which eliminates the need to use the string resource file.

icon

Specifies an image file associated with the template, located in the c8_location/webcontent/pat/images directory. The image appears as an icon in the new report dialog box.

Use a previously created image file for the custom report template.

Steps
  1. Open the Resources.xml.

    This file is located in the c8_location/webcontent/pat/res.

  2. Add a new listItem element using the label or idsLabel attribute for the custom report template.

    Here is an example of the edited file:

    <listView id="text-align">
    		<listItems>
    			<listItem value="" idsLabel="IDS_PROPVAL_DEFAULT"
    			 smallIcon="default_prop_value.gif"/>
    			<listItem value="left" idsLabel="IDS_PROPVAL_TALIGN_LEFT"
    			 smallIcon="hal/images/btn_align_left.gif"/>
    			<listItem value="center" idsLabel="IDS_PROPVAL_TALIGN_CENTER"
    			 smallIcon="hal/images/btn_align_center.gif"/>
    			<listItem value="right" idsLabel="IDS_PROPVAL_TALIGN_RIGHT"
    			 smallIcon="hal/images/btn_align_right.gif"/>
    			<listItem value="justify" idsLabel="IDS_PROPVAL_TALIGN_JUSTIFY"
    			 smallIcon="hal/images/btn_align_justify.gif"/>
    		</listItems>
    	</listView>
  3. Save and close the file.

You must now restart Report Studio for the custom report template to appear in the new report dialog box.