Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB Parsing - weird behavior
    text
    copied!<p>I am receiving a valid XML from server. lets say</p> <p><strong>XSD</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"&gt; &lt;xs:element name="rootElement"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element ref="elementOne"/&gt; &lt;xs:element ref="elementTwo"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="elementOne" type="elementOneType"/&gt; &lt;xs:complexType name="elementOneType"&gt; &lt;xs:sequence&gt; &lt;xs:element ref="childOne" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:element name="childOne" type="childOneType"/&gt; &lt;xs:complexType name="childOneType" mixed="true"&gt; &lt;xs:attribute name="One" type="xs:string" use="optional"/&gt; &lt;xs:attribute name="Two" type="xs:NMTOKEN" use="optional"/&gt; &lt;xs:attribute name="Three" type="xs:string" use="optional"/&gt; &lt;/xs:complexType&gt; &lt;xs:element name="elementTwo" type="elementTwoType"/&gt; &lt;xs:complexType name="elementTwoType"&gt; &lt;xs:sequence&gt; &lt;xs:element name="childTwo" type="childTwoType" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;xs:complexType name="childTwoType" mixed="true"&gt; &lt;xs:sequence&gt; &lt;xs:element ref="nestedChild" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xs:sequence&gt; &lt;xs:attribute name="One" type="xs:string" use="optional"/&gt; &lt;xs:attribute name="Two" type="xs:NMTOKEN" use="optional"/&gt; &lt;xs:attribute name="Three" type="xs:string" use="optional"/&gt; &lt;/xs:complexType&gt; &lt;xs:element name="nestedChild" type="nestedChildType"/&gt; &lt;xs:complexType name="nestedChildType"&gt; &lt;xs:attribute name="test" type="xs:string" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p><strong>XML</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;rootElement&gt; &lt;elementOne&gt; &lt;childOne One="532" Two="938" Three="changed"/&gt; &lt;/elementOne&gt; &lt;elementTwo&gt; &lt;childTwo One="532" Two="532" Three="68d53"/&gt; &lt;/elementTwo&gt; &lt;/rootElement&gt; </code></pre> <p>Could someone guide me what would be possible reason? I am unable to debugg from where should i start. the <strong>nestedChild</strong> is optional. so whenever JAXB parse the xml, it parse it in a way that if my xml doesn't have nestedChild, it shows 1 (empty object). if it has one nestedChild it shows 2, one valid and the other is empty. the transformation of valid child is okay, and obviously when the system try to convert empty object it throws exception .. </p> <p>its jaxb v 1.3</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload