I need to generate a report that requires nested groups to properly display data. Here is an example of the method I am using to nest groups:
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="nestedGroupReport">
<field name="country" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<group name="CountryGroup">
<groupExpression><![CDATA[$F{country}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement x="0" y="0" width="200" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["Country: " + $F{country}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement x="0" y="0" width="200" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["City Count: " + $V{cityCount}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
<group name="CityGroup">
<groupExpression><![CDATA[$F{city}]]></groupExpression>
<groupHeader>
<band height="20">
<textField>
<reportElement x="0" y="0" width="200" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["City: " + $F{city}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<!-- City group footer content -->
</band>
</groupFooter>
</group>
</group>
</jasperReport>
Whenever I use this structure, I get the following error:
cvc-complex-type.2.4.d: Invalid content was found starting with element 'group'. No child element is expected at this point. test.jrxml /MyReports line 25 JRXML Problem
I've tried putting "CityGroup" in different elements within "CountryGroup", but I just get similar errors.
To my understanding, nesting groups is a fundamental function of creating reports with Jasper, and I'm confused as to why this jrxml structure is not accepted within the current jrxml schema I'm using.
Does anyone know how I can successfully nest groups within Jaspersoft Studio 5.6.0?