Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.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

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解析-奇怪的行为_Java_Xml_Web Services_Jaxb - Fatal编程技术网

Java JAXB解析-奇怪的行为

Java JAXB解析-奇怪的行为,java,xml,web-services,jaxb,Java,Xml,Web Services,Jaxb,我正在从服务器接收有效的XML。比方说 XSD <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="rootElement"> <xs:complexType> <

我正在从服务器接收有效的XML。比方说

XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="rootElement">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="elementOne"/>
                <xs:element ref="elementTwo"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="elementOne" type="elementOneType"/>
    <xs:complexType name="elementOneType">
        <xs:sequence>
            <xs:element ref="childOne" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="childOne" type="childOneType"/>
    <xs:complexType name="childOneType" mixed="true">
        <xs:attribute name="One" type="xs:string" use="optional"/>
        <xs:attribute name="Two" type="xs:NMTOKEN" use="optional"/>
        <xs:attribute name="Three" type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:element name="elementTwo" type="elementTwoType"/>
    <xs:complexType name="elementTwoType">
        <xs:sequence>
            <xs:element name="childTwo" type="childTwoType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="childTwoType" mixed="true">
        <xs:sequence>
            <xs:element ref="nestedChild" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="One" type="xs:string" use="optional"/>
        <xs:attribute name="Two" type="xs:NMTOKEN" use="optional"/>
        <xs:attribute name="Three" type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:element name="nestedChild" type="nestedChildType"/>
    <xs:complexType name="nestedChildType">
        <xs:attribute name="test" type="xs:string" use="required"/>
    </xs:complexType>
</xs:schema>

XML

<?xml version="1.0" encoding="UTF-8"?>
<rootElement>
    <elementOne>
        <childOne One="532" Two="938" Three="changed"/>
    </elementOne>
    <elementTwo>
        <childTwo One="532" Two="532" Three="68d53"/>
    </elementTwo>
</rootElement>

有人能告诉我可能的原因吗?我无法从哪里开始调试。 嵌套子项是可选的。因此,每当JAXB解析xml时,它都会以这样一种方式解析它:如果我的xml没有nestedChild,它将显示1(空对象)。如果它有一个nestedChild,则显示2,一个有效,另一个为空。有效子对象的转换是正常的,显然,当系统尝试转换空对象时,它会抛出异常


它的JAXBV 1.3

您可以说您从服务器收到了一个有效的XML;你真的验证了吗?该行为闻起来好像缺少结束元素。请使用xmlspy之类的工具打开xml并进行验证。这看起来不像是jaxb问题。请提供完整的xml文件和模式。如果你不能,试着建立一个最小的例子来重现你的问题。如果您在构建它的过程中发现错误,很好:-)您能建议如何转储XML吗。我尝试使用tcpmon,但它没有显示我的xml请求/响应。我的应用程序在weblogic server的外部端口8001上运行,我正在eclipse中使用远程调试挂钩在端口5001上调试它。JAXB 1.3?那是史前的,你确定吗?