I answer to my question, in case it can help someone else.

The solution I've found is to use my own parser wrapper class.
It looks like
public class CustomXMLReader extends StAXReaderWrapper implements 
IXMLReader {

     public CustomXMLReader(XMLStreamReader rdr, String name, boolean nsa) {
         super(rdr, name, nsa);
     }

     @Override
     public String getNamespace(){
         String ns = super.getNamespace();
         if ( "".equals(ns)){
             return "uri2";
         }
         return ns;
     }
}

( idea coming from this thread 
http://www.mail-archive.com/jibx-users@lists.sourceforge.net/msg02726.html )

Cheers
Jean-Michel


Le 20/01/2011 16:13, Jean-Michel FRANCOIS a écrit :
> Hi,
>
> I'm facing a problem with a web services provider that uses 
> (incorrectly) 2 namespaces in its messages.
> In a first service I receive something like
> <a xmlns="uri1">
> <b xmlns="uri2">
> <c/>
> </b>
> </a>
>
> But in a second one I have
> <aa xmlns="uri1">
> <b xmlns=""> <!-- <= should be xmlns="uri2" -->
> <c/>
> </b>
> </aa>
>
> b element is defined in namespace "uri2" in the schema thus codegen 
> generates the correct binding.
> Of course when parsing the second response Jibx complains about the 
> unknown b element.
> The problem comes from the ws provider's response, but there is no 
> chance to see it being corrected.
>
> In xmlbeans, that I'm currently migrating from, I used a namespace 
> substitution at parse time with
>         Map<String, String> prefixes = new HashMap<String, String>();
>         prefixes.put("", "uri2");
>         XmlOptions.setLoadSubstituteNamespaces(prefixes);
>
> Does exist, in Jibx, something like setLoadSubstituteNamespaces ?
>
> If not, by which customization can I handle such a case ?
>
>
> Thank you for your help
> Jean-Michel

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to