Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JAXB没有按预期解析.xsd。C#从同一文件自动生成_Java_Xml_Jaxb_Xsd - Fatal编程技术网

Java JAXB没有按预期解析.xsd。C#从同一文件自动生成

Java JAXB没有按预期解析.xsd。C#从同一文件自动生成,java,xml,jaxb,xsd,Java,Xml,Jaxb,Xsd,我对JAXB当前从.xsd文件生成java对象的方式有一些问题。下面是我正在使用的.xsd文件的代码片段。此代码的目的是,它将有一个逻辑设备列表,这些逻辑设备是包含各种信息的对象 <xs:element name="LogicalDeviceList"> <xs:annotation> <xs:doc

我对JAXB当前从.xsd文件生成java对象的方式有一些问题。下面是我正在使用的.xsd文件的代码片段。此代码的目的是,它将有一个逻辑设备列表,这些逻辑设备是包含各种信息的对象

                        <xs:element name="LogicalDeviceList">
                            <xs:annotation>
                                <xs:documentation>List of all LogicalDevices currently added for the application</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element name="LogicalDevice" minOccurs="0" maxOccurs="unbounded">
                                        <xs:annotation>
                                            <xs:documentation>An added logical device</xs:documentation>
                                        </xs:annotation>
                                        <xs:complexType>
                                            <xs:attribute name="DeviceDefinitionId" use="required">
                                                <xs:annotation>
                                                    <xs:documentation>The DeviceDefinitionId of the Logical device</xs:documentation>
  .......... Other LogicalDevice Information

当前为应用程序添加的所有逻辑设备的列表
添加的逻辑设备
逻辑设备的DeviceDefinitionId
.......... 其他逻辑设备信息
目前,JAXB解析器创建一个对象,其中LogicalDeviceList不是LogicalDevices列表,LogicDevice返回DeviceDefinitionId列表

由于我接收和解压的XML无论如何都无法更改,有没有办法解决这个问题?它是否像将.xsd文件更改为这样简单

更新:以下修改无效。5-24-2013

                        <xs:element name="LogicalDeviceList" minOccurs="0" maxOccurs="unbounded">
                            <xs:annotation>
                                <xs:documentation>List of all LogicalDevices currently added for the application</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element name="LogicalDevice">
                                        <xs:annotation>
                                            <xs:documentation>An added logical device</xs:documentation>
                                        </xs:annotation>
                                        <xs:complexType>
                                            <xs:attribute name="DeviceDefinitionId" use="required">
                                                <xs:annotation>
                                                    <xs:documentation>The DeviceDefinitionId of the Logical device</xs:documentation>

当前为应用程序添加的所有逻辑设备的列表
添加的逻辑设备
逻辑设备的DeviceDefinitionId

如果是这样,为什么C#.xsd解析器按照预期从原始xsd生成对象和列表,而JAXB没有

对于XML架构片段:

<xs:element name="LogicalDeviceList">
    <xs:annotation>
        <xs:documentation>List of all LogicalDevices currently added for the application</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="LogicalDevice" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>An added logical device</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:attribute name="DeviceDefinitionId" use="required">
                        <xs:annotation>
                            <xs:documentation>The DeviceDefinitionId of the Logical device</xs:documentation>
                        ...   

JAXB可能与C#生成的内容不完全匹配,但它是XML模式的一种完全可接受的表示形式。

由于修改不起作用,除了JAXB之外,还有其他选项可以解析.xsd文件并按预期创建对象。很难从部分模式进行诊断,您可以发布更多信息吗?我是EclipseLink JAXB(MOXy)的负责人,请随时通过以下链接与我联系:感谢您的回复Blaise,我已按要求向您发送电子邮件。谢谢,我会看一看。
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "logicalDevice"
    })
    public static class LogicalDeviceList {

        @XmlElement(name = "LogicalDevice")
        protected List<LogicalDeviceList.LogicalDevice> logicalDevice;