
Using Zen Reports
Version 2018.1
2019-05-30
InterSystems Corporation 1 Memorial Drive Cambridge MA 02142 www.intersystems.com

Using Zen Reports
Caché Version 2018.1 2019-05-30
Copyright © 2019 InterSystems Corporation
All rights reserved.
InterSystems, InterSystems Caché, InterSystems Ensemble, InterSystems HealthShare, HealthShare, InterSystems TrakCare, TrakCare,
InterSystems DeepSee, and DeepSee are registered trademarks of InterSystems Corporation.
InterSystems IRIS Data Platform, InterSystems IRIS, InterSystems iKnow, Zen, and Caché Server Pages are trademarks of InterSystems
Corporation.
All other brand or product names used herein are trademarks or registered trademarks of their respective companies or organizations.
This document contains trade secret and confidential information which is the property of InterSystems Corporation, One Memorial Drive,
Cambridge, MA 02142, or its affiliates, and is furnished for the sole purpose of the operation and maintenance of the products of InterSystems
Corporation. No part of this publication is to be used for any other purpose, and this publication is not to be reproduced, copied, disclosed,
transmitted, stored in a retrieval system or translated into any human or computer language, in any form, by any means, in whole or in part,
without the express prior written consent of InterSystems Corporation.
The copying, use and disposition of this document and the software programs described herein is prohibited except to the limited extent
set forth in the standard software license agreement(s) of InterSystems Corporation covering such programs and related documentation.
InterSystems Corporation makes no representations and warranties concerning such software programs other than those set forth in such
standard software license agreement(s). In addition, the liability of InterSystems Corporation for any losses or damages relating to or arising
out of the use of such software programs is limited in the manner set forth in such standard software license agreement(s).
THE FOREGOING IS A GENERAL SUMMARY OF THE RESTRICTIONS AND LIMITATIONS IMPOSED BY INTERSYSTEMS
CORPORATION ON THE USE OF, AND LIABILITY ARISING FROM, ITS COMPUTER SOFTWARE. FOR COMPLETE INFORMATION
REFERENCE SHOULD BE MADE TO THE STANDARD SOFTWARE LICENSE AGREEMENT(S) OF INTERSYSTEMS CORPORATION,
COPIES OF WHICH WILL BE MADE AVAILABLE UPON REQUEST.
InterSystems Corporation disclaims responsibility for errors which may appear in this document, and it reserves the right, in its sole discretion
and without notice, to make substitutions and modifications in the products and practices described in this document.
For Support questions about any InterSystems products, contact:
InterSystems Worldwide Response Center (WRC)
+1-617-621-0700Tel:
+44 (0) 844 854 2917Tel:
suppor[email protected]Email:

Table of Contents
About This Book .................................................................................................................................... 1
Zen Reports Attribute Data Types .................................................................................................... 1
1 Introducing Zen Reports .................................................................................................................... 3
1.1 Background Reading .................................................................................................................. 4
1.2 Zen Report Tutorial .................................................................................................................... 5
2 Gathering Zen Report Data ............................................................................................................. 11
2.1 XData ReportDefinition ........................................................................................................... 12
2.2 The %val Variable ..................................................................................................................... 15
2.2.1 Where %val is Supported ............................................................................................. 276
2.2.2 Multidimensional Values of %val ................................................................................ 276
2.3 <report> and <group> .............................................................................................................. 17
2.3.1 <report> and <group> Attributes ................................................................................... 17
2.3.2 Building the <report> or <group> Query ....................................................................... 20
2.3.3 Break On Field or Expression ........................................................................................ 25
2.3.4 Nested Groups ................................................................................................................ 28
2.3.5 Sibling Groups ............................................................................................................... 29
2.3.6 Conditionally Generated Groups ................................................................................. 276
2.4 Value Nodes .............................................................................................................................. 31
2.4.1 Handling White Space .................................................................................................. 276
2.4.2 Value Node Attributes .................................................................................................... 32
2.4.3 <element> ....................................................................................................................... 35
2.4.4 <attribute> ...................................................................................................................... 38
2.4.5 <aggregate> .................................................................................................................... 40
2.5 DATASOURCE ........................................................................................................................ 46
2.6 Including an XML Data Source ............................................................................................... 47
2.6.1 Writing XML Statements From a Class Method ........................................................... 47
2.6.2 <call> ............................................................................................................................. 48
2.6.3 <callelement> ................................................................................................................. 51
2.6.4 <include> ....................................................................................................................... 53
2.6.5 <macrodef> .................................................................................................................... 54
2.6.6 <get> .............................................................................................................................. 55
2.7 Generating a Report from a Class Query ................................................................................. 55
2.8 Restructuring the ReportDefinition XML ................................................................................ 57
2.9 Gathering Data in the ReportDisplay Block ............................................................................ 57
3 Formatting Zen Report Pages ......................................................................................................... 59
3.1 XData ReportDisplay ............................................................................................................... 60
3.2 Finding Data with XPath Expressions ...................................................................................... 60
3.3 The id Attribute ........................................................................................................................ 64
3.4 Dimension and Size .................................................................................................................. 64
3.5 International Number Formats ................................................................................................. 65
3.6 Default Format and Style ......................................................................................................... 65
3.7 Pagination and Layout .............................................................................................................. 65
3.7.1 The <document> element and Page Layout ................................................................... 65
3.7.2 Conditional Page Margins and Regions ......................................................................... 72
3.7.3 Resetting the Page Count for Each Element of a Group ................................................ 74
3.7.4 Multiple Display Layouts ............................................................................................... 75
Using Zen Reports iii

3.7.5 Keeping Display Components Together ......................................................................... 77
3.7.6 Conditionally Including a Group’s Elements ................................................................. 78
3.7.7 Writing Mode ................................................................................................................. 80
3.8 Supported Fonts for Complex Scripts ...................................................................................... 80
3.8.1 Arabic ........................................................................................................................... 276
3.8.2 Devanagari ................................................................................................................... 276
3.9 Conditional Expressions for Displaying Elements ................................................................... 82
3.9.1 ifexpression .................................................................................................................... 83
3.9.2 ifxpath ............................................................................................................................ 83
3.9.3 includeColIfExpression .................................................................................................. 84
3.9.4 includeColUnlessExpression ......................................................................................... 84
3.9.5 includeColIfXPath .......................................................................................................... 84
3.9.6 includeColUnlessXPath ................................................................................................. 84
3.9.7 unlessexpression ............................................................................................................. 85
3.10 Conditional Expressions for Displaying Values ..................................................................... 85
3.11 <report> .................................................................................................................................. 86
3.12 <init> ...................................................................................................................................... 88
3.13 <xslt> ...................................................................................................................................... 89
3.13.1 <xslt> and its Attributes ............................................................................................... 89
3.13.2 XData Blocks for <xslt> .............................................................................................. 90
3.13.3 Setting XSLT Global Variables with <xslt> ................................................................. 91
3.14 <section> ................................................................................................................................ 92
3.15 <pagemaster> ......................................................................................................................... 92
3.16 <masterreference> .................................................................................................................. 92
3.17 <document> ............................................................................................................................ 92
3.17.1 <class> ......................................................................................................................... 99
3.17.2 <cssinclude> ............................................................................................................... 101
3.17.3 <xslinclude> ............................................................................................................... 101
3.18 <pageheader> ....................................................................................................................... 102
3.19 <pagefooter> ........................................................................................................................ 103
3.20 <pagestartsidebar> ............................................................................................................... 104
3.21 <pageendsidebar> ................................................................................................................. 104
3.22 <body> ................................................................................................................................. 105
3.22.1 <call> ......................................................................................................................... 107
3.22.2 <fo> ............................................................................................................................ 110
3.22.3 <foblock> ................................................................................................................... 110
3.22.4 <html> ........................................................................................................................ 111
3.22.5 <write> ....................................................................................................................... 111
4 Displaying Zen Report Data .......................................................................................................... 113
4.1 Report Display Attributes ....................................................................................................... 114
4.2 Conditionally Applying CSS Styles ....................................................................................... 116
4.3 <barcode> ............................................................................................................................... 117
4.4 <barcodeOptions> .................................................................................................................. 118
4.5 <block> ................................................................................................................................... 119
4.6 <bidioverride> ........................................................................................................................ 119
4.7 <br/> ....................................................................................................................................... 121
4.8 <container> ............................................................................................................................. 121
4.9 <div> ...................................................................................................................................... 123
4.10 <group> ................................................................................................................................ 125
4.11 <header> and <footer> ......................................................................................................... 127
iv Using Zen Reports

4.12 <img> ................................................................................................................................... 128
4.13 <inline> ................................................................................................................................ 129
4.14 <inlinecontainer> ................................................................................................................. 130
4.15 <item> .................................................................................................................................. 131
4.15.1 field ............................................................................................................................ 136
4.15.2 special ......................................................................................................................... 136
4.15.3 ofString ....................................................................................................................... 276
4.15.4 suppressDuplicates ..................................................................................................... 137
4.15.5 Page Numbering in Multi-section Reports ................................................................. 137
4.16 <line> ................................................................................................................................... 137
4.17 <link> ................................................................................................................................... 138
4.18 <list> .................................................................................................................................... 139
4.19 <p> ....................................................................................................................................... 141
4.20 <pagebreak> ......................................................................................................................... 141
4.21 <small-multiple> .................................................................................................................. 142
4.22 <table> .................................................................................................................................. 144
4.22.1 The orderby Attribute in ReportDisplay ..................................................................... 149
4.22.2 Centering a <table> for PDF Output .......................................................................... 150
4.22.3 Displaying Elements in a <table> .............................................................................. 150
4.22.4 <caption> ................................................................................................................... 153
4.22.5 <summary> ................................................................................................................ 154
4.22.6 Using Complex Headers for a <table> ....................................................................... 156
4.22.7 Embedding a <table> within a <table> ...................................................................... 157
4.22.8 Zen Reports Cross Tab Tables .................................................................................... 276
4.22.9 Creating Type 2 Cross Tab Tables .............................................................................. 157
4.22.10 Creating Type 1 Cross Tab Tables ............................................................................ 164
4.22.11 Creating Tables with a Callback Method ................................................................. 171
4.22.12 Creating Tables From Class Queries ........................................................................ 172
4.22.13 Creating Tables with SQL ........................................................................................ 172
4.22.14 Creating Tables with onCreateResultSet .................................................................. 173
4.23 <timeline> ............................................................................................................................ 173
5 Building Zen Report Classes ......................................................................................................... 177
5.1 Controlling Zen Reports with Parameters .............................................................................. 177
5.1.1 Class Parameters .......................................................................................................... 177
5.1.2 SQL Query Parameters ................................................................................................ 276
5.1.3 Data Type Parameters ................................................................................................... 276
5.1.4 XSLT Stylesheet Parameters ........................................................................................ 276
5.1.5 URI Query Parameters ................................................................................................. 276
5.2 Using Runtime Expressions in Zen Reports .......................................................................... 179
5.3 Localizing Zen Reports .......................................................................................................... 180
5.3.1 Adding Entries to the Message Dictionary .................................................................. 276
5.3.2 Localization for Excel Output ...................................................................................... 276
5.4 Organizing Zen Reports to Reuse Code ................................................................................. 182
5.5 Using Zen Report Composites ............................................................................................... 183
5.5.1 Creating a Composite to Define Style .......................................................................... 183
5.5.2 Creating a Composite to Define Layout ...................................................................... 185
5.5.3 Referencing a Composite from a Zen Report .............................................................. 186
5.6 Using Zen Report Templates .................................................................................................. 188
5.6.1 Creating a Zen Report Template .................................................................................. 189
5.6.2 Referencing a Zen Report Template ............................................................................. 189
Using Zen Reports v