本文介绍了尝试将xmi反序列化为CAS对象时出现XCASParsingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使Ruta脚本从Java运行,并将生成的CAS对象转换为如下所示的xmi文件;

I have made Ruta scripts run from Java and have converted the resulting CAS object into an xmi file as below;

FileOutputStream fileOutputStream = new FileOutputStream(outputXmiFile);
XmiCasSerializer.serialize(cas, fileOutputStream);

当我尝试将其转换回CAS对象(在另一台服务器上)时,如下所示;

When I try to convert it back into a CAS object (on another server), as below;

FileInputStream fileInputStream = new FileInputStream(xmiFile);
XmlCasDeserializer.deserialize(fileInputStream, cas);

我得到以下例外

XCASParsingException: Error parsing XCAS or XMI-CAS from source <unknown> at line <unknown>, column <unknown>: unknown type: NULL.

异常的快照.

推荐答案

是的,谢谢!它起作用了!

Ya Thanks ! It worked !

import org.apache.uima.util.CasIOUtils;

CAS到XMI

CasIOUtils.save(cas, fileOutputStream, SerialFormat.XMI);

XMI到CAS

CasIOUtils.load(fileInputStream, cas);

这篇关于尝试将xmi反序列化为CAS对象时出现XCASParsingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 06:03