Gagnon, Jean-Philippe (LTI)
2008-01-30 21:27:17 UTC
Hi,
I'm trying to marshall a collection of String in an element with a
constant attribute as in this example
Java:
private List<String> myItems = new ArrayList<String>();
XML:
<Item version="V2">item1</Item>
<Item version="V2">item2</Item>
<Item version="V2">item3</Item>
I was expecting this binding to work :
<collection field="myItems" create-type="java.util.ArrayList">
<structure name="Item" >
<value style="attribute" name="version" constant="V2"/>
<value style="text" type="java.lang.String"/>
</structure>
</collection>
But I get this exception from the binding compiler:
Error: <value> elements within a collection must define element name for
unmarshalling; on value element at (line 72, col 54, in
./binding/scenarioBinding.xml)
[bind] Error: Type must be specified on outermost <structure>
element within collection; on structure element at (line 70, col 32, in
./binding/scenarioBinding.xml)
I have also tried to add the type="java.lang.String" to the structure
element but it gives me this exception
[bind] *** Error during code generation for file
'./binding/scenarioBinding.xml' - please enter a bug report for this
error in Jira if the problem is not listed as fixed on the online status
page ***
[bind] java.lang.IllegalStateException: Internal error: Expected
org.jibx.runtime.impl.MarshallingContext on stack, found
java.lang.String
[bind] full stack:
[bind] 0: org.jibx.runtime.impl.MarshallingContext
[bind] 1: java.lang.String
[bind] 2: java.lang.String
[bind] 3: int
[bind] 4: java.lang.String
[bind] 5: java.lang.String
[bind] at
org.jibx.binding.classes.MethodBuilder.verifyCompatible(MethodBuilder.ja
va:420)
Am I missing something obvious?
Thank you
JP
I'm trying to marshall a collection of String in an element with a
constant attribute as in this example
Java:
private List<String> myItems = new ArrayList<String>();
XML:
<Item version="V2">item1</Item>
<Item version="V2">item2</Item>
<Item version="V2">item3</Item>
I was expecting this binding to work :
<collection field="myItems" create-type="java.util.ArrayList">
<structure name="Item" >
<value style="attribute" name="version" constant="V2"/>
<value style="text" type="java.lang.String"/>
</structure>
</collection>
But I get this exception from the binding compiler:
Error: <value> elements within a collection must define element name for
unmarshalling; on value element at (line 72, col 54, in
./binding/scenarioBinding.xml)
[bind] Error: Type must be specified on outermost <structure>
element within collection; on structure element at (line 70, col 32, in
./binding/scenarioBinding.xml)
I have also tried to add the type="java.lang.String" to the structure
element but it gives me this exception
[bind] *** Error during code generation for file
'./binding/scenarioBinding.xml' - please enter a bug report for this
error in Jira if the problem is not listed as fixed on the online status
page ***
[bind] java.lang.IllegalStateException: Internal error: Expected
org.jibx.runtime.impl.MarshallingContext on stack, found
java.lang.String
[bind] full stack:
[bind] 0: org.jibx.runtime.impl.MarshallingContext
[bind] 1: java.lang.String
[bind] 2: java.lang.String
[bind] 3: int
[bind] 4: java.lang.String
[bind] 5: java.lang.String
[bind] at
org.jibx.binding.classes.MethodBuilder.verifyCompatible(MethodBuilder.ja
va:420)
Am I missing something obvious?
Thank you
JP