iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library
iReport Ultimate GuideCode Example 11-3Example XML file, continuedPeacockMargaretTo select only the people contained in the categories (that is, all the people in the address book), use the following expression:/addressbook/category/personFour nodes will be returned. These are shown in Table 11-1.Code Example 11-4DavolioNancyFullerAndrewLeverlingPeacockMargaretIf you want to select the people appearing in the favorites node, the expression to use is/addressbook/favorites/personTwo nodes will be returned nodes.Node set with expression /addressbook/category/personHere is another expression. It is a bit more complex, but it shows all the power of the Xpath language. The idea is to select theperson nodes belonging to the work category. The expression to use is the following:/addressbook/category[@name = "work"]/personThe expression will return only one node, that with an ID equal to 4, as shown here.PeacockMargaret188
Data Sources and Query ExecutersAfter you have created an expression for the selection of a node set, you can proceed to the creation of an XML data source.Open the window for creating a new data source and select XML File data source from the list of connection types to bring upthe dialog box shown in Figure 11-18.Figure 11-18 Configuring an XML data sourceThe only mandatory information to specify is the XML file name. Optionally, you can provide a set of nodes, using a predefinedstatic XPath expression. Alternatively, the XPath expression can be set directly inside the report.I always suggest that you use a report-defined XPath expression. The advantage of this solution is the ability to use parametersinside the XPath expression, which acts like a real query on the supplied XML data. Optionally, you can specify Java patternsto convert dates and numbers from plain strings to more appropriate Java objects (like Date and Double). For the samepurpose, you can define a specific locale and time zone to use when parsing the XML stream.11.6.4 Registration of the Fields for an XML Data SourceIn the case of an XML data source, the definition of a field in the report needs a particular expression inserted as a fielddescription in addition to the type and the name. As the data source aims always to be one node of the selected node set, theexpressions are relative to the current node.To select the value of an attribute of the current node, use the following syntax:@For example, to define a field that must point to the id attribute of a person (attribute id of the node person), it is sufficient tocreate a new field, name it as you want, and set the description to@idSimilarly, it is possible to get to the child nodes of the current node. For example, if you want to refer to the lastname node,child of person, use the following syntax:lastname189
- Page 137 and 138: TemplatesCHAPTER 9TEMPLATESOne of t
- Page 139 and 140: TemplatesFigure 9-2Columnar reportA
- Page 141 and 142: TemplatesFigure 9-4Group by step in
- Page 143 and 144: TemplatesIf a static text element i
- Page 145 and 146: TemplatesFigure 9-8Your custom temp
- Page 147 and 148: TemplatesFigure 9-10New template in
- Page 149 and 150: TemplatesFigure 9-12Preview of repo
- Page 151 and 152: SubreportsCHAPTER 10 SUBREPORTSSubr
- Page 153 and 154: SubreportsFigure 10-3Subreport elem
- Page 155 and 156: SubreportsFigure 10-4Subreport Para
- Page 157 and 158: SubreportsFigure 10-7Just a list of
- Page 159 and 160: SubreportsFigure 10-11 Subreport Wi
- Page 161 and 162: SubreportsFigure 10-14 The final re
- Page 163 and 164: Subreports3. Click the Add button t
- Page 165 and 166: Subreports10.4 Using the Subreport
- Page 167 and 168: SubreportsFigure 10-21 Subreport co
- Page 169 and 170: SubreportsFigure 10-23 Setting Subr
- Page 171 and 172: Data Sources and Query ExecutersCHA
- Page 173 and 174: Data Sources and Query Executers•
- Page 175 and 176: Data Sources and Query ExecutersFig
- Page 177 and 178: Data Sources and Query ExecutersFig
- Page 179 and 180: Data Sources and Query ExecutersFig
- Page 181 and 182: Data Sources and Query ExecutersFig
- Page 183 and 184: Data Sources and Query ExecutersFig
- Page 185 and 186: Data Sources and Query ExecutersFig
- Page 187: Data Sources and Query Executers•
- Page 191 and 192: Data Sources and Query ExecutersIns
- Page 193 and 194: Data Sources and Query Executerspub
- Page 195 and 196: Data Sources and Query ExecutersFig
- Page 197 and 198: Data Sources and Query ExecutersFig
- Page 199 and 200: Data Sources and Query Executersbe
- Page 201 and 202: Data Sources and Query ExecutersFig
- Page 203 and 204: Data Sources and Query ExecutersWhe
- Page 205 and 206: Data Sources and Query ExecutersCod
- Page 207 and 208: Data Sources and Query ExecutersPre
- Page 209 and 210: Data Sources and Query ExecutersFig
- Page 211 and 212: Data Sources and Query Executersspe
- Page 213 and 214: Data Sources and Query Executers•
- Page 215 and 216: Data Sources and Query Executersof
- Page 217 and 218: Data Sources and Query ExecutersThi
- Page 219 and 220: Data Sources and Query ExecutersCod
- Page 221 and 222: Data Sources and Query ExecutersIf
- Page 223 and 224: ChartsCHAPTER 12 CHARTSUR provides
- Page 225 and 226: ChartsFigure 12-3Chart selection wi
- Page 227 and 228: ChartsFigure 12-6Dataset configurat
- Page 229 and 230: settings). These four fields have t
- Page 231 and 232: ChartsFigure 12-10 Chart Theme Desi
- Page 233 and 234: ChartsFigure 12-12 Example chart th
- Page 235 and 236: Run your report. iReport should dis
- Page 237 and 238: Charts1. First create a report.Figu
Data Sources and Query ExecutersAfter you have created an expression for the selection of a node set, you can proceed to the creation of an XML data source.Open the window for creating a new data source and select XML File data source from the list of connection types to bring upthe dialog box shown in Figure 11-18.Figure 11-18 Configuring an XML data sourceThe only mandatory information to specify is the XML file name. Optionally, you can provide a set of nodes, using a predefinedstatic XPath expression. Alternatively, the XPath expression can be set directly inside the report.I always suggest that you use a report-defined XPath expression. The advantage of this solution is the ability to use parametersinside the XPath expression, which acts like a real query on the supplied XML data. Optionally, you can specify Java patternsto convert dates and numbers from plain strings to more appropriate Java objects (like Date and Double). For the samepurpose, you can define a specific locale and time zone to use when parsing the XML stream.11.6.4 Registration of the Fields for an XML Data SourceIn the case of an XML data source, the definition of a field in the report needs a particular expression inserted as a fielddescription in addition to the type and the name. As the data source aims always to be one node of the selected node set, theexpressions are relative to the current node.To select the value of an attribute of the current node, use the following syntax:@For example, to define a field that must point to the id attribute of a person (attribute id of the node person), it is sufficient tocreate a new field, name it as you want, and set the description to@idSimilarly, it is possible to get to the child nodes of the current node. For example, if you want to refer to the lastname node,child of person, use the following syntax:lastname189