Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got error at iReport 5.6 on opening JRXML: "Attribute 'hTextAlign' is not allowed to appear in element 'style'"

Has anyone ever gotten this error in iReport 5.6 when trying to open the jrxml file?

Attribute 'hTextAlign' is not allowed to appear in element 'style'

like image 974
Jeremias Santos Avatar asked Mar 28 '17 14:03

Jeremias Santos


People also ask

How do I open Jrxml in Jaspersoft Studio?

jrxml. In Jaspersoft Studio, navigate to My Reports > reports. Find and double-click the agent_activity. jrxml file to open it.

What is Jrxml file in Jasper?

What is a JRXML file? A JRXML file is created by JasperReports and contains design definition in popular XML file format. It stores all the design elements such as report layout, text fields, images, charts, parameters, and variables.

How do I compile Jrxml to Jasper file in eclipse?

jrxml report and rightclick on it. In context menu choose 'Compile report'. Then you get compiled . jasper report.


1 Answers

The cause of problem

The jrxml file is just a xml file. It is a common practice to validate xml files with help of XSD schema.

The JasperReports engine is doing the same - it is using xsd schema to validate the report's template (jrxml file).

The xsd was changed at 6.x version compared with 5.x version.

The schema for latest version of JasperReports is available with url. You can always find the link to schema at header of jrxml file:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ... xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" ...>

Looks like your template (jrxml file) was created or edited with JasperReports Studio of 6.x version and saved without applying compatitbility with 5.x version option (Compatibility warning dialog).

How to solve this issue:

  1. You can use Jaspersoft Studio (JSS) for modifying report's template. Maybe it is the best choice because the iReport is deprecated (it is not supported since the end of 2015 year) and supports only 5.6 and oldest versions of JasperReports templates/features.

  2. You can save the template at compatitbility mode as 5.x version at JSS and after this continue edit the jrxml file with iReport

The dialog appears during saving template at JSS and looks like this:

Dialog at JSS

To enable this dialog you should change settings at form called via Window -> Preferences menu.

Preferences at JSS

  1. Always use only iReport designer. But be aware: it does not support 6+ version of JasperReports templates.

How to check the difference in schemas of 5.x and 6.x versions

The xsd schema for any version of JasperReports can be found at JasperReports package with source code or at repository of source code.

This is a fragment (screenshot) of comparing xsd files of 5.6.1 (left panel) and 6.3.0 (right panel) versions.

Diff of two xsd

As you can see that the hTextAlign attribute from your error message presents only at xsd of 6.x version. This is a cause of the error you got

like image 50
Alex K Avatar answered Sep 18 '22 13:09

Alex K