Hi,
I have a following XML document:
<?xml version="1.0" encoding="UTF-8" ?>
<taskConf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pduda.com.pl taskConf.xsd"
xmlns="http://pduda.com.pl">
<task xsi:type="softwareDownload" shortName="download">
<gid>111</gid>
<p1>222</p1>
<p2>333</p2>
</task>
<task xsi:type="softwareUpload" shortName="upload">
<gid>111</gid>
</task>
</taskConf>
I want to bind it as a TaskConf class with a list of tasks (abstract
Class). Each of the tasks would extend the abstract class to:
SoftwareUpload or SoftwareDownload classes. Of course, there are more.
I've tried it with many binding.xml's. Here's one generated by xsd2JiBX:
<?xml version="1.0" encoding="UTF-8"?>
<binding>
<mapping name="task" class="pl.com.pduda.CoreTask">
<namespace uri="http://pduda.com.pl" default="elements"/>
<value name="shortName" field="shortName" usage="optional"
style="attribute"/>
</mapping>
<mapping name="softwareUpload" class="pl.com.pduda.SoftwareUpload">
<namespace uri="http://pduda.com.pl" default="elements"/>
<structure map-as="pl.com.pduda.CoreTask"/>
<value name="gid" field="gid" usage="required"/>
</mapping>
<mapping name="softwareDownload"
class="pl.com.pduda.SoftwareDownload">
<namespace uri="http://pduda.com.pl" default="elements"/>
<structure map-as="pl.com.pduda.CoreTask"/>
<value name="gid" field="gid" usage="required"/>
<value name="p1" field="p1" usage="required"/>
<value name="p2" field="p2" usage="required"/>
</mapping>
<mapping name="taskConf" class="pl.com.pduda.TaskConf">
<namespace uri="http://pduda.com.pl" default="elements"/>
<collection field="taskList">
<structure map-as="pl.com.pduda.CoreTask"/>
</collection>
</mapping>
</binding>
Unfortunately it crashes at run-time:
Exception in thread "main" org.jibx.runtime.JiBXException: Expected
"{http://pduda.com.pl}taskConf" end tag, found
"{http://pduda.com.pl}softwareDownload" start tag (line 5, col 42)
at
org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(Unmars
hallingContext.java:800)
at
pl.com.pduda.JiBX_SWMGMT_testEJB_binding__jibxClasses_com_pl_pduda_bindi
ngTaskConf_access.unmarshal()
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(Unmarshallin
gContext.java:2773)
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(Unmarshalli
ngContext.java:2916)
at pl.com.pduda.main.StarterXML.main(StarterXML.java:73)
Any ideas on how to implement this? Thank you!
Kind regards,
Pawel Duda
-------------------------
Pawel Duda
mobile: +48 784 031 665
e-mail: [email protected] <mailto:[email protected]>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users