Hi Nick,

This is somewhat confusing, and the naming of the attributes used in the 
binding probably contributes to the confusion. The ns attribute needs to 
give the actual namespace URI (as stated in the documentation on these 
attributes: 
http://jibx.sourceforge.net/binding/binding-attributes.html), not the 
prefix. So this should work:

<mapping name="Product" class="com.myCode.xxxProductFile">
    <namespace name="ns1" uri="http://ns1"; default="elements"/>
    <namespace name="ns2" uri="http://ns2"; default="none"/>
    <structure ns="http://ns2"; name="metaDataProperty">
          <structure name="ProductMetaData">
               <value name="fileIdentifier" field="fileId"/>

(where I've changed the ns value on the first <structure> element).

When you tried the binding in its original form you should have gotten 
an error which said something about namespace not defined - didn't this 
happen?

  - 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



Scott, Nick wrote:
> Hi, I'm looking for guidance on the best approach to handling 
> multiple, alternating, namespaces in jibx. The tutorial hints at a 
> solution:
>  
> http://jibx.sourceforge.net/binding/tutorial/binding-advanced.html
> "...This makes the namespace automatically apply to every name 
> definition unless you override it with a specific namespace using the 
> ns attribute...."
>  
> but provides no example. Try as I might, I keep getting validation 
> errors whatever permutation of attributes I go for!
>  
> The problem XML is long and tedious with five different namespaces all 
> interspersed! To illustrate the problem, consider the following fragment:
>  
> ...
> <metadata>
>  <ns1:Product xsi:schemaLocation="http://earth.esa.int/geca 
> ./xsd/geca/geca.xsd" xmlns:ns1="http://ns1 <http://ns1/>" 
> xmlns:ns2="http://ns2 <http://ns2/>">
>   <ns2:metaDataProperty>
>    <ns1:ProductMetaData>
>     <ns1:fileIdentifier>urn:x-geca:avdc:500</geca:fileIdentifier>
>     ...
>  
> If the <ns2:metaDataProperty> is simply removed, then the following works:
>  
> ...
> <mapping name="Product" class="com.myCode.xxxProductFile">
>     <namespace name="ns1" uri="http://ns1 <http://ns1/>" 
> default="elements"/>
>           <structure name="ProductMetaData">
>                <value name="fileIdentifier" field="fileId"/>
>                   ...
>  
> Logically, I would expect a something like:
>  
> ...
> <mapping name="Product" class="com.myCode.xxxProductFile">
>     <namespace name="ns1" uri="http://ns1 <http://ns1/>" 
> default="elements"/>
>     <namespace name="ns2" uri="http://ns2 <http://ns2/>" default="none"/>
>     <structure ns="ns2" name="metaDataProperty">
>           <structure name="ProductMetaData">
>                <value name="fileIdentifier" field="fileId"/>
>                   ...
>  
> or
>  
> ...
> <mapping name="Product" class="com.myCode.xxxProductFile">
>     <namespace name="ns1" uri="http://ns1 <http://ns1/>" default="none"/>
>     <namespace name="ns2" uri="http://ns2 <http://ns2/>" default="none"/>
>     <structure ns="ns2" name="metaDataProperty">
>           <structure ns="ns1" name="ProductMetaData">
>                <value ns="ns1" name="fileIdentifier" field="fileId"/>
>                   ...
>  
> to do the trick - but they both lead to compilation errors ("Namespace 
> prefix conflict for namespace element").
>  
> Is there a "right" approach to alternating namespaces in this manner? 
> All help would be much appreciated!
>  
> Nick
>  
>
> Please help Logica to respect the environment by not printing this 
> email / Pour contribuer comme Logica au respect de l'environnement, 
> merci de ne pas imprimer ce mail / Bitte drucken Sie diese Nachricht 
> nicht aus und helfen Sie so Logica dabei, die Umwelt zu schützen. / 
> Por favor ajude a Logica a respeitar o ambiente não imprimindo este 
> correio electrónico. This e-mail and any attachment is for authorised 
> use by the intended recipient(s) only. It may contain proprietary 
> material, confidential information and/or be subject to legal 
> privilege. It should not be copied, disclosed to, retained or used by, 
> any other party. If you are not an intended recipient then please 
> promptly delete this e-mail and any attachment and all copies and 
> inform the sender. Thank you.
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to