The namespace handling is a little awkward with JiBX 1.x. You've
basically got two ways of doing this. The first (and easiest) is to use
separate binding definitions for the Response element and the Struc
element, using a different namespace as the default for each (and
<include>ing the second binding in the first). The second is to define
one of the namespaces with default="elements" and the other with
default="none", then reference the one with default="none" as needed on
individual elements. Since The www.blah.org namespace is only used on
Response, in this case I'd make the webservice.blah.com the one with
default="elements" and just specify the namespace on the Response
mapping - so:
<binding name="outRequestDO">
<mapping name="Response" class="org.mystuff.dos.myDO"
ns="http://www.blah.org/blah1">
<namespace uri="http://www.blah.org/blah1" default="none"
prefix="ns1"/>
<namespace uri="http://webservice.blah.com/" default="elements"
prefix=""/>
<collection field="Strucs"
factory="org.jibx****ntime.Utility.arrayListFactory" usage="optional">
<structure name="Struc" type="org.mystuff.dos.myStrucDO"
ordered="false" flexible="true" usage="optional">
<value name="field1" field="field1" usage="optional"/>
<value name="field2" field="field2" usage="optional"/>
</structure>
</collection>
</mapping>
</binding>
I think you do need to specify different prefixes when the namespaces
are declared at the same level in this way, but otherwise this should
match what you want. If you really need to use both namespaces without
prefixes I think the separate binding definitions approach should allow
you to do that.
See http://jibx.sourceforge.net/binding/namespace-element.html and the
tutorial for more on namespace usage.
- Dennis
Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
On 08/11/2010 05:48 AM, mailc...@vt.edu wrote:
> Trying to bind this XML:
> [code]
> <?xml version="1.0" encoding="UTF-8"?>
> <Response xmlns="http://www.blah.org/blah1"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <Struc xmlns="http://webservice.blah.com/">
> <field1>1165337</field1>
> <field2>2010</field2>
> </Struc >
> <Struc xmlns="http://webservice.blah.com/">
> <field1>1165337</field1>
> <field2>2010</field2>
> </Struc >
> ...
> </Response>
> [/code]
>
> is there any way for JiBX to ignore the namespace at the structure level?
>
> At runtime JiBX errors out with expecting
> {http://www.blah.org/blah1}Response
> <http://www.blah.org/blah1%7DResponse> end tag but found
> {http://webservice.blah.com/}Struc
> <http://webservice.blah.com/%7DStruc> start tag
>
> Binding file:
> [code]
> <binding name="outRequestDO">
> <mapping name="Response" class="org.mystuff.dos.myDO">
> <namespace uri="http://www.blah.org/blah1" default="elements"
> prefix=""/>
> <collection field="Strucs"
> factory="org.jibx****ntime.Utility.arrayListFactory" usage="optional">
> <structure name="Struc" type="org.mystuff.dos.myStrucDO"
> ordered="false" flexible="true" usage="optional">
> <value name="field1" field="field1" usage="optional"/>
> <value name="field2" field="field2" usage="optional"/>
> </structure>
> </collection>
> </mapping>
> </binding>
> [/code]
>
> Any way to bind that structure?
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
>
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users