4

docx4j(我托管)通常与 Sun/Oracle JAXB 实现一起使用;下面感兴趣的类是使用 XJC 生成的。

MOXy 人员友好修复的较早问题之后,我将继续尝试使其与 EclipseLink MOXy 一起使用。

对于特定的 DOM 文档,我现在得到:

[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])]
    at org.eclipse.persistence.jaxb.JAXBBinder.unmarshal(JAXBBinder.java:100)
    at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.unmarshal(JaxbXmlPartXPathAware.java:211)
    at org.docx4j.openpackaging.io.LoadFromZipNG.getRawPart(LoadFromZipNG.java:556)
    at org.docx4j.openpackaging.io.LoadFromZipNG.getPart(LoadFromZipNG.java:427)
    at org.docx4j.openpackaging.io.LoadFromZipNG.addPartsFromRelationships(LoadFromZipNG.java:350)
    at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:243)
    at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:301)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:245)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:195)
    at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:178)
    at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:172)
    at org.docx4j.samples.OpenAndSaveRoundTripTest.main(OpenAndSaveRoundTripTest.java:60)
Caused by: Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.exceptions.XMLMarshalException.unmarshalException(XMLMarshalException.java:109)
    at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.startElement(XMLCompositeObjectMappingNodeValue.java:328)
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:783)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:147)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.handleChildNodes(DOMReader.java:250)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.reportElementEvents(DOMReader.java:148)
    at org.eclipse.persistence.internal.oxm.record.DOMReader.parse(DOMReader.java:89)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:462)
    at org.eclipse.persistence.oxm.XMLBinder.unmarshal(XMLBinder.java:84)
    at org.eclipse.persistence.jaxb.JAXBBinder.unmarshal(JAXBBinder.java:89)
    ... 12 more
Caused by: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:851)
    at org.eclipse.persistence.internal.oxm.XMLRelationshipMappingNodeValue.processChild(XMLRelationshipMappingNodeValue.java:91)
    at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.startElement(XMLCompositeObjectMappingNodeValue.java:323)
    ... 36 more
Caused by: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])
    at org.eclipse.persistence.exceptions.DescriptorException.noFieldValueConversionToAttributeValueProvided(DescriptorException.java:1052)
    at org.eclipse.persistence.mappings.converters.ObjectTypeConverter.convertDataValueToObjectValue(ObjectTypeConverter.java:140)
    at org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getAttributeValue(XMLDirectMapping.java:287)
    at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.attribute(XMLDirectMappingNodeValue.java:153)
    at org.eclipse.persistence.oxm.record.UnmarshalRecord.startElement(UnmarshalRecord.java:834)
    ... 38 more

那是与 JAXBBinder.unmarshall 一起使用的。如果我使用 JAXBUnmarshaller.unmarshal,也会发生同样的事情:

[Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: Exception [EclipseLink-116] (Eclipse Persistence Services - 2.4.0.v20120529-r11529): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: No conversion value provided for the value [1] in field [@ns1:val].
Mapping: org.eclipse.persistence.oxm.mappings.XMLDirectMapping[val-->@ns1:val]
Descriptor: XMLDescriptor(org.docx4j.math.CTOnOff --> [])]
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:956)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:210)

导致损坏的 XML 文件可以在https://gist.github.com/2834081org.docx4j.math.CTOnOff 找到

有什么建议么?

4

1 回答 1

5

注意: 我是EclipseLink JAXB (MOXy)的负责人,也是JAXB (JSR-222)专家组的成员。

被解组的 XML 文档实际上是无效的。如果ns1:val属性中的值被更改以匹配允许的枚举值,那么一切都会按预期工作。

XML 文件

xml doc 的第 95 行是这个

<m:radPr>
    <m:degHide m:val="1" />

停止关闭

1 不是有效值...应该是“开”或“关”

@XmlType(name = "ST_OnOff")
@XmlEnum
public enum STOnOff {

    @XmlEnumValue("on")
    ON("on"),
    @XmlEnumValue("off")
    OFF("off");
    private final String value;

}

CTRadPr

public class CTRadPr  implements Child
{
    protected CTOnOff degHide;
    protected CTCtrlPr ctrlPr;
    ...
}

CTOnOff

@XmlType(name = "CT_OnOff")
public class CTOnOff  implements Child
{
    @XmlAttribute(namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math")
    protected STOnOff val;

MOXy 中有一个与处理无效值相关的错误。MOXy 应该做的是,当它发现无效值时,它应该向ValidationEventHandler. 如果ValidationEventHandler处理事件,则不会为相应的字段/属性设置值。当您使用 JAXB RI 尝试此操作时,您将看到无效值未填充到对象模型中

您可以使用以下错误来跟踪我们在此问题上的进展:


更新

我们已修复EclipseLink 2.4.0 流中的错误 381217。您可以从以下位置下载夜间标签:

注意: 通过修复,MOXy 将报告无效属性值的验证事件,就像它报告无效元素值一样。这与 JAXB-RI 的行为不同,它为无效元素而不是无效属性引发验证事件。我相信 RI 行为是一个错误。

于 2012-05-31T15:15:09.217 回答