Jump to content
Changes to the Jaspersoft community edition download ×

isSplitAllowed vs. splitType


ejhellerattc

Recommended Posts

I am having a problem with the compilation of reports. I am using the API compilation(via compileReportToFile). The compilation fails with the following messages:

Feb 4, 2010 9:35:00 AM net.sf.jasperreports.engine.xml.JRBandFactory createObject
WARNING: The 'isSplitAllowed' attribute is deprecated. Use the 'splitType' attribute instead.
Feb 4, 2010 9:35:00 AM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 35 column 44: cvc-complex-type.3.2.2: Attribute 'splitType' is not allowed to appear in element 'band'.
 

The section of the file it is complaining about is:

        <background>
            <band height="0" isSplitAllowed="false"/>
        </background>
        <title>
            <band height="83"  splitType="Stretch" >

               |

            </band>
 

This was happening with version 3.5.2, so I updated to 3.7.1 and am still getting the same messages. This file will also not load into iReports with the same basic error, however creating a blank report generates statements that it is happy with.

Thoughts?

Thanks,

Ed.

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

We have deprecated the isSplitAllowed attribute when we replaced it with the new splitType attribute.

Basically, isSplitAllowed="false" is equvalent to splitType="Prevent".

 

I'm not sure why you compile your reports at runtime, because in most cases you don't:

http://jasperforge.org/website/jasperreportswebsite/trunk/faq.html?group_id=102#FAQ22?header=project&target=jasperreports

 

If your reports are somehow dynamic you need to create them at runtime and compile them at runtime, then you need to change your program that creates those reports and no longer use the deprecated API to setSplitAllowed(), but the setSplitType().

However, if you have static JRXML files, you don't need to compile them at runtime, because you can compile them with Ant, at application build time:

http://jasperreports.sourceforge.net/sample.reference/antcompile/index.html#antcompile

 

If you have many JRXML files and you want to bring them up to date and use the new JRXML syntax, there is an Ant task for the job as well. It was added in the latest release and you can see an example here:

http://jasperreports.sourceforge.net/sample.reference/antupdate/index.html#antupdate

Basically what this task does is to load your reports and save them back, using the new syntax.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

Thanks for the quick response. Our reporting process is two fold. We generate many static reports that reference a well defined dynamic XML data source. At runtime, based on user selection, we generate a dynamic JRXML file that calls the needed static reports as subreports. This is then compiled and displayed. The problem started with a static report that would not display in iReports, giving an error message like:

Attribute 'splitType' is not allowed to appear in element 'band'.

Since I could not determine which line caused the problem, I used our "compile" method to compile this file and the output told me which line the error appears on. This was an older report that had been using isSplitAllowed. I modified the file to use splitType (selecting Prevent  for false and Stretch for true). When I used iReports to verify the report, I got the above error. I changed the first splitType back to isSplitAllowed to see what would happen. I then ran it through the "compile" method, since it provides the details with the exception message. This told me that the error was on the second band with the first reference to splitType. So - my question is why would I get the error message above given the code snippet from the JRXML file.

BTW: I do not wish to get into a discussion about whether dynamic reports should be generated using API calls or generating and compiling a JRXML file. The latter works for us and is much easier to debug, as I can observe the generated JRXML file to verify proper data references and positions.

Thanks,

Ed.

Link to comment
Share on other sites

Hi,

 

When you upgrade JR, make sure you also upgrade iReport, because they go hand in hand.

If iReport complains about an unknown splitType attribute, it means iReport is older and you should upgrade it to a newer version. Also, recent versions of iReport are able to save JRXML in older formats, so there is basically no reason for you not to upgrade iReport.

 

I hope this helps.
Teodor

Link to comment
Share on other sites

I found the solution. As I mentioned, the file was an older report that used isSplitAllowed. it also had an incorrect header. It had

1) <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
 

and

2) only had <jasperReport. Not the additional referential attributes:

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"

 

I am not sure which parts of the latter are required, but removing the DOCTYPE and adding the additional attributes to the jasperReport element(?) allows everything to work correctly.

Thanks,

Ed.

Link to comment
Share on other sites

  • 4 years later...
  • 1 year later...

@xclusiveProgrammer the solution from @ejhellerattc is to remove the DOCTYPE declaration line and add the xml namespace tags (which he pasted above) in the <jasperReport > tag. You can also see this by creating a hello world report in latest version of iReport and open the jrxml in a text editor.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...