Jeremias Santos
Jeremias Santos

Reputation: 197

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'

Upvotes: 7

Views: 5041

Answers (4)

EFessler
EFessler

Reputation: 49

Use isStretchWithOverflow="true" instead of textAdjust="StretchHeight"

Upvotes: 0

Nausheen
Nausheen

Reputation: 1

I had the same problem while trying to parse an XML document. It worked after removing the textAdjust property from the report source XML. All values gives exception: CutText, StretchHeight and ScaleFont.

Upvotes: 0

GAUTAM KRISHNA M S
GAUTAM KRISHNA M S

Reputation: 1

Remove all attribute textAdjust="StretchHeight" in textField tag. I have removed the attribute and it worked fine for me Screen.

Upvotes: 0

Alex K
Alex K

Reputation: 22867

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

Upvotes: 7

Related Questions