有没有人在 iReport 5.6 中尝试打开 jrxml 文件时遇到过这个错误?
Attribute 'hTextAlign' is not allowed to appear in element 'style'
最佳答案
问题的原因
jrxml 文件只是一个 xml 文件。在 XSD schema 的帮助下验证 xml 文件是一种常见做法。 .
JasperReports 引擎也在做同样的事情——它使用 xsd 模式来验证报告的模板(jrxml 文件)。
与 5.x 版本相比,6.x 版本更改了 xsd。
最新版本的 JasperReports 模式可通过 url 获得。 .您始终可以在 jrxml 文件的标题中找到指向架构的链接:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ... xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" ...>
看起来您的模板(jrxml 文件)是使用 6.x 版本的 JasperReports Studio 创建或编辑的,并且保存时没有应用与 5.x 版本选项的兼容性(兼容性警告对话框)。如何解决这个问题:
在 JSS 中保存模板时会出现该对话框,如下所示:
要启用此对话框,您应该在通过 Window -> Preferences 菜单调用的表单中更改设置。
如何检查 5.x 和 6.x 版本的架构差异
任何版本的 JasperReports 的 xsd 模式都可以在 JasperReports 包和源代码或源代码存储库中找到。
这是比较 5.6.1(左面板)和 6.3.0(右面板)版本的 xsd 文件的片段(屏幕截图)。
如您所见,
hTextAlign
您的错误消息中的属性仅在 6.x 版本的 xsd 中出现。这是你得到的错误的原因
关于jasper-reports - 在 iReport 5.6 打开 JRXML : "Attribute ' hTextAlign' is not allowed to appear in element 'style' "时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43072862/