带有“意外元素:CDATA"消息的 org.apache.xmlbeans.XmlException 是什么?意思? [英] What does the org.apache.xmlbeans.XmlException with a message of "Unexpected element: CDATA" mean?

查看:33
本文介绍了带有“意外元素:CDATA"消息的 org.apache.xmlbeans.XmlException 是什么?意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析和加载 XML 文档,但是当我在扩展 XmlObject 的类上调用 parse 方法时出现此异常.不幸的是,它让我不知道什么元素是意外的,这是我的问题.

I'm trying to parse and load an XML document, however I'm getting this exception when I call the parse method on the class that extends XmlObject. Unfortunately, it gives me no ideas of what element is unexpected, which is my problem.

我无法共享此代码,但如有必要,我可以尝试提供更多信息.

I am not able to share the code for this, but I can try to provide more information if necessary.

推荐答案

无法共享代码或输入数据,您可以考虑以下方法.恐怕这是一种非常常见的二分法诊断,而且您可能已经开始使用它了...

Not being able to share code or input data, you may consider the following approach. That's a very common dichotomic approach to diagnostic, I'm afraid, and indeed you may readily have started it...

尝试通过删除部分 XML 来减小输入 XML 的大小,确保底层 XML 文档保持良好的格式并且可能有效(如果解析器的设置需要有效性).如果您保持有效性,这可能需要更改 [a copy of] Schema(DTD 或其他),因为在剪切和尝试方法期间可能会删除强制元素......顺便说一句,错误消息似乎更多地暗示一个验证问题,一个基本的格式良好的断言问题.

Try and reduce the size of the input XML by removing parts of it, ensuring that the underlying XML document remains well formed and possibly valid (if validity is required in your parser's setup). If you maintain validity, this may require to alter [a copy of] the Schema (DTD or other), as manditory elements might be removed during the cut-and-try approach... BTW, the error message seems to hint more at a validation issue that a basic well-formedness assertion issue.

除非有人对触发解析器抱怨的区域有特别的预感,否则我们通常会删除(或重新添加,当事情开始工作时)大约一半的先前删除或重新添加的内容.

Unless one has a particular hunch as to the area that triggers the parser's complaint, we typically remove (or re-add, when things start working) about half of what was previously cut or re-added.

您也可以从尝试一个大部分为空的文件开始,以断言解析器确实可以工作......再次出现划分以占上风"的想法:问题是在 XML 输入中还是在解析器中?(记住可能有两个问题,一个在输入中,一个在解析器中,而且这些问题甚至可能是无关的...)

You may also start with trying a mostly empty file, to assert that the parser does work at all... There again is the idea to "divide to prevail": is the issue in the XML input or in the parser ? (remembering that there could be two issues, one in the input and one in the parser, and thtat such issues could even be unrelated...)

很抱歉,您可能已经精通基本的诊断技术......

Sorry to belabor basic diagnostics techniques which you may well be fluent with...

这篇关于带有“意外元素:CDATA"消息的 org.apache.xmlbeans.XmlException 是什么?意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆