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

后端 未结 2 1623
青春惊慌失措
青春惊慌失措 2020-12-21 05:53

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

Attribute \'hTextAlign\' is not allowed to appe

相关标签:
2条回答
  • 2020-12-21 06:28

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

    0 讨论(0)
  • 2020-12-21 06:39

    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:

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

    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.

    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

    0 讨论(0)
提交回复
热议问题