Hello,
I have a problem with parsing a document after calling a get-method of an
attribute which has an abstract type and returns a specific type at the time.
It means that I have an object already assigned to the attribute when parsing
to the associated element of the xml document and want to update this object.
The problem is, the getter is called and returns a derived type which will be
set immediately via the setter without parsing the element.
After that an exception will be thrown showing that the next xml element is
expected but the parser has stopped at the element what was not fully parsed.
If I don't use a superclass as "Inhaber" all goes as expected. The existing
object will be used and updated with the values from the xml document.
This behavior looks like a bug to me or am I doing anything wrong here?
Thanks in advance
Mathias
binding - file:
<mapping name="Steuerkonto" class="xmlbinding.Steuerkonto"
pre-set="preset" post-set="postset">
<structure name="Inhaber">
<structure set-method="setInhaber"
get-method="getInhaber" pre-set="presetInhaber"/>
<structure name="AdrKette">
<collection add-method="addAdresse"
iter-method="createAdressIterator" type="xmlbinding.Steuerkonto"
item-type="xmlbinding.Adresse">
<structure map-as="xmlbinding.StrAdr"/>
<structure
map-as="xmlbinding.GrossempfAdr"/>
<structure
map-as="xmlbinding.PostfAdr"/>
</collection>
</structure>
</structure>
</mapping>
<mapping class="xmlbinding.NatUndNNatPerson" abstract="true">
</mapping>
<mapping name="NNatPers" class="xmlbinding.NNatPers"
extends="xmlbinding.NatUndNNatPerson">
<value name="name" set-method="setName" get-method="getName"
usage="required" style="attribute"/>
</mapping>
<mapping name="NatPers" class="xmlbinding.NatPers"
extends="xmlbinding.NatUndNNatPerson">
<value name="lastname" set-method="setLastname"
get-method="getLastname" usage="required" style="attribute"/>
<value name="firstname" set-method="setFirstname"
get-method="getFirstname" usage="optional" style="attribute"/>
</mapping>
<mapping name="StrAdr" class="xmlbinding.StrAdr">
<structure map-as="Adresse"/>
<value name="str" field="str" usage="required"
style="attribute"/>
</mapping>
<mapping name="GrossempfAdr" class="xmlbinding.GrossempfAdr">
<structure map-as="Adresse"/>
<value name="grempfname" field="grempfname" usage="required"
style="attribute"/>
</mapping>
<mapping name="PostfAdr" class="xmlbinding.PostfAdr">
<structure map-as="Adresse"/>
<value name="postf" field="postf" usage="required"
style="attribute"/>
</mapping>
<mapping type-name="Adresse" class="xmlbinding.Adresse" abstract="true">
<value name="Plz" field="plz" usage="required"/>
<value name="ort" field="ort" usage="required"
style="attribute"/>
<value name="adressArt" field="adressArt" usage="optional"
style="attribute"/>
</mapping>
extract from Steuerkonto.java:
protected NatUndNNatPerson inhaber;
public NatUndNNatPerson getInhaber() {
if (inhaber==null) {
inhaber=new NNatPers(); // simulating existing object
}
System.out.println("getInhaber: " + this.inhaber);
return this.inhaber;
}
public void setInhaber(NatUndNNatPerson inhaber) {
System.out.println("setInhaber: " + inhaber);
this.inhaber = inhaber;
}
XML-document
<Steuerkonto>
<Inhaber>
<NNatPers name="NichtnatPerson"/>
<AdrKette>
<StrAdr ort="String" adressArt="String" str="String">
<Plz>String</Plz>
</StrAdr>
<GrossempfAdr ort="String" adressArt="String"
grempfname="String">
<Plz>String</Plz>
</GrossempfAdr>
<PostfAdr ort="String" adressArt="String"
postf="String">
<Plz>String</Plz>
</PostfAdr>
</AdrKette>
</Inhaber>
</Steuerkonto>
Exception:
getInhaber: [EMAIL PROTECTED]
setInhaber: [EMAIL PROTECTED]
org.jibx.runtime.JiBXException: Expected "{http://xmlbinding}AdrKette" start
tag, found "{http://xmlbinding}NNatPers" start tag (line 5, col 36)
at
org.jibx.runtime.impl.UnmarshallingContext.throwStartTagNameError(Unknown
Source)
at org.jibx.runtime.impl.UnmarshallingContext.matchStart(Unknown Source)
at org.jibx.runtime.impl.UnmarshallingContext.parsePastStartTag(Unknown
Source)
at xmlbinding.Steuerkonto.JiBX_bindings_unmarshal_1_0(Steuerkonto.java)
at
xmlbinding.JiBX_JiBXTest2_bindings_bindingsSteuerkonto_access.unmarshal()
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(Unknown
Source)
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(Unknown
Source)
at org.jibx.extras.TestRoundtrip.runTest(Unknown Source)
at org.jibx.extras.TestRoundtrip.main(Unknown Source)
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users