【发布时间】:2012-06-07 15:35:07
【问题描述】:
我想使用 JiBX 来解组大型 XML 文件,但我不希望它针对 XSD 进行验证。我该怎么做?
概念证明(适用于符合 XSD 的 XML 的 jUnit sn-p):
IBindingFactory bfact = BindingDirectory.getFactory(Customer.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Customer customer = (Customer) uctx.unmarshalDocument(new FileInputStream(fileLocation), null);
我为什么需要这个?我有一个 RESTful 服务,允许用户上传巨大的 XML 文件。 Castor 被证明对这项工作来说太慢了,我现在正在用 JiBX 重写东西。虽然,我从经验中知道,用户有时会上传 99.9% 可处理的文件,但元素中的一个额外 XML 属性会使整个 XML 不正确。我仍然想在内存中解组所有我能做的事情并手动进行验证。
【问题讨论】:
标签: xsd unmarshalling castor jibx