Hi,
I am trying to bind XML to Java Objects with JiBX.
But now I have a problem with collections in binding.xml.
I need two collection in my binding.
My java classes look like:
class Classname {
private String element1;
private String element2;
private String elem;
private String elem1;
private String elem21;
private String elem22;
private ArrayList<Node> nodes;
}
class Node {
private String nodename;
private ArrayList<NodeChild> children;
}
class NodeChild {
private String elem;
}
The number of nodes and NodeChilds is different per each XML-File.
The XML-File looks like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<classname id="xyz">
<element1>foo</element1>
<element2>bar</element2>
<otherelems>...</otherelems>
<structure>
<elem>foo</elem>
<elem1>bar</elem>
</structure>
<otherelems>...</otherelems>
<structure2>
<elem21>foo</elem21>
<elem22>bar</elem22>
</structure2>
<otherelems>...</otherelems>
<node name="foo">
<otherelems>...</otherelems>
<nodename>name</nodename>
<nodechild name="child1">
<elem>first</elem>
<otherelems>...</otherelems>
</nodechild>
<nodechild name="anotherchild">
<elem>first</elem>
<otherelems>...</otherelems>
</nodechild>
<otherelems>...</otherelems>
</node>
<node name="anothernode">
<otherelems>...</otherelems>
<nodename>name</nodename>
<nodechild name="child1">
<elem>first</elem>
<otherelems>...</otherelems>
</nodechild>
<nodechild name="anotherchild">
<elem>first</elem>
<otherelems>...</otherelems>
</nodechild>
<otherelems>...</otherelems>
</node>
</classname>
So I wrote the following binding.xml:
<binding direction="input">
<mapping name="classname" class="model.Classname" ordered="false"
flexible="true">
<value style="attribute" name="id" field="id"/>
<value name="element1" field="element1"/>
<value name="element2" field="element2"/>
<structure name="structure" flexible="true" ordered="false">
<value name="elem" field="elem"/>
<value name="elem1" field="elem1"/>
</structure>
<structure name="structure2" flexible="true" ordered="false">
<value name="elem21" field="elem21"/>
<value name="elem22" field="elem22"/>
</structure>
<collection name="node"/>
</mapping>
<mapping name="node" class="model.Node" ordered="false"
flexible="true">
<value name="nodename" field="nodename"/>
<collection name="nodechild"/>
</mapping>
<mapping name="nodechild" class="model.Nodechild" ordered="false"
flexible="true">
<value name="elem" field="elem"/>
</mapping>
</binding>
But I can't execute with this binding.
I get an Exception: "No unmarshaller for elem" (with elem in NodeChild).
Can anyone help me to fix this problem?
Thanks,
veote
--
View this message in context:
http://old.nabble.com/jibx-bind%3A-handle-flexible-%2B-collection-tp33285341p33285341.html
Sent from the jibx-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users