The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

hippozheng (3) [Avatar] Offline
#1
<namespace> cannot appear at the <structure> level in jibx
I am new to the jibx library. And when I ran the example in chapter 3 regarding to the jiBx example, I found the following config doesn't work with jibx1.x:

<binding>
<mapping name="person" class="org.demo.Person">
<namespace uri="http://demo/persons" >
default="elements"/>
<value name="firstname" field="firstName" />
<value name="lastname" field="lastName" />
<structure name="address" field="address" >
class="org.demo.Address">
<namespace uri="http://demo/address" >
default="elements"/>
<value name="city" field="city" />
<value name="country" field="country" />
</structure>
</mapping>
</binding>

I found this should be an enhancement which was scheduled to be fixed in the coming 2.x. So, how do you run it successfully?

Please refer to:
http://jira.codehaus.org/browse/JIBX-30
hippozheng (3) [Avatar] Offline
#2
Re: &lt;namespace&gt; cannot appear at the &lt;structure&gt; level in jibx
I got the following validation error:

[INFO] Running JiBX binding compiler (single-module mode) on 1 binding file(s)
Running binding compiler version jibx_1_1_6
Unable to process binding person-binding.xml
org.jibx.runtime.JiBXException: Expected "structure" end tag, found "namespace" start tag (line 8, col 62, in person-bin
ding.xml)
at org.jibx.runtime.impl.UnmarshallingContext.parsePastCurrentEndTag(UnmarshallingContext.java:800)
at org.jibx.binding.model.JiBX_bindingStructureElement_access.unmarshal()
at org.jibx.binding.model.NestingElementBase.JiBX_binding_unmarshal_2_1(NestingElementBase.java)
at org.jibx.binding.model.ContainerElementBase.JiBX_binding_unmarshal_3_0(ContainerElementBase.java)
at org.jibx.binding.model.TemplateElementBase.JiBX_binding_unmarshal_4_0(TemplateElementBase.java)
at org.jibx.binding.model.MappingElement.JiBX_binding_unmarshal_5_0(MappingElement.java)
at org.jibx.binding.model.JiBX_bindingMappingElement_access.unmarshal()
at org.jibx.binding.model.BindingElement.JiBX_binding_unmarshal_3_0(BindingElement.java)
at org.jibx.binding.model.JiBX_bindingBindingElement_access.unmarshal()
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2773)
at org.jibx.binding.model.BindingElement.readBinding(BindingElement.java:760)
at org.jibx.binding.model.BindingElement.readBinding(BindingElement.java:776)
at org.jibx.binding.model.BindingElement.validateBinding(BindingElement.java:794)
at org.jibx.binding.Utility.validateBinding(Utility.java:223)
at org.jibx.binding.Utility.loadBinding(Utility.java:264)
tijs.rademakers (494) [Avatar] Offline
#3
Re: &lt;namespace&gt; cannot appear at the &lt;structure&gt; level in jibx
Hi,

Which version of the book's source code are you using?
The current version has the following mapping.xml file for chapter 3:

<binding>
<mapping name="person" class="esb.chapter3.Person">
<value name="customer-number" field="customerNumber"/>
<value name="first-name" field="firstName"/>
<value name="last-name" field="lastName"/>
<value name="street" field="street"/>
<value name="city" field="city"/>
<value name="state" field="state"/>
<value name="zip" field="zip"/>
<value name="phone" field="phone"/>
</mapping>
</binding>

So no namespace element there. You can also look at the esbinaction.com website under the source code link to get more information how to get the latest source code.

Best regards,

Tijs
hippozheng (3) [Avatar] Offline
#4
Re: &lt;namespace&gt; cannot appear at the &lt;structure&gt; level in jibx
Dear Tijis,

Thanks a lot for replying. I got the code from the book[Listing 3.9 An example of a JiBX binding file with namespaces].

<binding>
<mapping name="person" class="org.demo.Person">
<namespace uri="http://demo/persons" >
default="elements"/>
<value name="firstname" field="firstName" />
<value name="lastname" field="lastName" />
<structure name="address" field="address" >
class="org.demo.Address">
<namespace uri="http://demo/address" >
default="elements"/>
<value name="city" field="city" />
<value name="country" field="country" />
</structure>
</mapping>
</binding>


Many thanks and Best Regards,

James
tijs.rademakers (494) [Avatar] Offline
#5
Re: &lt;namespace&gt; cannot appear at the &lt;structure&gt; level in jibx
smilie, I should have looked at the book.
Hope you got it working now.

Best regards,

Tijs