Hi, there - sorry for the long post, but XML unmarshalling issues tend
to be fairly complex; TIA to anybody who actually reads through this
whole thing.

I'm trying to use Jibx (beta 3c) to deal with an XML structure which
might or might not contain repeating elements in the middle, so a sample
might look like this:

<sample>
  <first>this is the first element</first>
  <repeater>
    <elem1>value1</elem1>
    <elem2>value2</elem2>
  <repeater>
  <repeater>
    <elem1>value3</elem1>
    <elem2>value4</elem2>
  <repeater>
  <second>this is the second element</second>
</sample>

Or:

<sample>
  <first>this is the first element</first>
  <second>this is the second element</second>
</sample>

The catch is, I don't really care about the middle (repeating) elements
in this case, so I want to skip over them.  My original jibx binding
looked like this (the add-method was added to get around a jibx compiler
error):

<binding direction="input">
  <mapping name="sample" class="com.sample.Sample">
    <value name="first" field="first" />
    <collection name="repeater" usage="optional"
add-method="addIgnored">
      <structure>
        <value name="elem1" />
        <value name="elem2" />
      </structure>
    </collection>
    <value name="second" field="second" />
  </mapping>
</binding>

This actually fails with an "IllegalStateException" at link time (stack
trace below slightly modified to make it more readable):

java.lang.IllegalStateException: Stack size mismatch on branch
 in method com.sample.Sample.JiBX_sample_binding_unmarshal
 generated by [EMAIL PROTECTED]
 from stack:
  0: com.sample.Sample
  1: java.lang.String
 to stack:
  0: com.sample.Sample

at
org.jibx.binding.classes.BranchWrapper.setTarget(BranchWrapper.java:184)
at
org.jibx.binding.classes.BranchWrapper.setTarget(BranchWrapper.java:201)
at
...def.NestedCollection.genContentUnmarshal(NestedCollection.java:134)
at ...def.ElementWrapper.genContentUnmarshal(ElementWrapper.java:272)
at ...def.NestedStructure.genContentUnmarshal(NestedStructure.java:150)
at ...def.ObjectBinding.genUnmarshalContentCall(ObjectBinding.java:611)
at ...def.ObjectBinding.genContentUnmarshal(ObjectBinding.java:723)
at ...def.ElementWrapper.genContentUnmarshal(ElementWrapper.java:272)
at ...def.MappingDefinition.generateCode(MappingDefinition.java:498)
at ...def.DefinitionContext.generateCode(DefinitionContext.java:600)
at ...def.BindingDefinition.generateCode(BindingDefinition.java:555)
at org.jibx.binding.Compile.compile(Compile.java:299)
at org.jibx.binding.Compile.main(Compile.java:364)
Exception in thread "main"

So I switched things around like this:

<binding direction="input">
  <mapping name="sample" class="com.sample.Sample">
    <value name="first" field="first" />
    <collection usage="optional" add-method="addIgnored">
      <structure name="repeater">        
        <value name="elem1" />
        <value name="elem2" />
      </structure>
    </collection>
    <value name="second" field="second" />
  </mapping>
</binding>

But I get essentially the same error.

It seems to me that there's enough context in the definition to get
around this, so I must be missing something.  Any thoughts? 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to