In XML it's not supposed to matter whether something is a default namespace or a prefixed namespace, except for QNames in content (something JiBX doesn't directly support, at present). So the following XML document is equivalent to your original one for all normal purposes:

<a xmlns="ns:a" xmlns:nsb="ns:b">
 <nsb:b/>
</a>

This form could easily be generated with JiBX. If you really need the form with both namespaces as defaults you should also be able to do that, assuming you can make the binding definition for the Java value corresponding to the element <b/> a <mapping>. Then you'd have two mappings, each containing their own default namespace declaration.

For 2.0 I'll look into a more flexible way of handling namespace declarations, but for 1.0 they're limited to being declared as children of the <binding> element itself (in which case they apply to all top-level <mapping>s) or as children of a <mapping> element.

Hope that helps clarify the issues.

 - Dennis

Chris Chen wrote:

Hi,

I came across an issue with binding files. How does one deal with namespace declarations for something like the following?

<a xmlns="ns:a">
    <b xmlns="ns:b"/>
</a>

If my binding file looks something like:

<binding>
    <namespace uri="ns:a" default="elements"/>
    <mapping name="a" field="a" ns="ns:a">
        <structure name="b" field="b" ns="ns:b"/>
    </mapping>
</binding>

compiling this binding of course will give me an error stating that namespace ns:b was not declared.

Unfortunately, I have to declare the namespace either globally or within the <mapping> element. This requires me to give the namespace a prefix. In this setup, the marshalled xml will be something like the following:

<a xmlns="ns:a" xmlns:b="ns:b">
    <b:b/>
</a>

Is there a way for me to create an xml like the original with the binding files? I'm probably just missing some configuration that I am not aware of.

Thanks
Chris



-------------------------------------------------------
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_id=6595&alloc_id=14396&op=click
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to