gpt4 book ai didi

jaxb - XMLDirectMapping - 未提供转化值(value)

转载 作者:行者123 更新时间:2023-12-03 07:27:44 26 4
gpt4 key购买 nike

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

继之前的问题 MOXy guys kindly fixed ,我将继续尝试使其与 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)

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

有什么建议?

最佳答案

注: 我是 EclipseLink JAXB (MOXy) 领导 JAXB (JSR-222) 专家组成员。

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

XML 文件

xml 文档的第 95 行是这个

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

STOnOff

1 不是有效值...应该是“on”或“off”
@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 尝试此操作时,您将看到无效值未填充到对象模型中

您可以使用以下错误来跟踪我们在此问题上的进展:
  • http://bugs.eclipse.org/381217


  • 更新

    我们已修复 EclipseLink 2.4.0 流中的 bug 381217。您可以从以下位置下载每晚标签:
  • http://www.eclipse.org/eclipselink/downloads/nightly.php

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

    关于jaxb - XMLDirectMapping - 未提供转化值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10811078/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com