[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-users
Subject:    Re: [jibx-users] mixing namespaced elements with non-namespaced
From:       Dennis Sosnoski <dms () sosnoski ! com>
Date:       2008-11-30 23:25:53
Message-ID: 49332101.5020805 () sosnoski ! com
[Download RAW message or body]

Hi Neeme,

The approach of using ns="" on the <value> element really should work in 
this case, since you specified a prefix for your namespace (meaning 
you're not making it the default namespace inside XML documents). If you 
want to enter a Jira report along with a sample project build I'll track 
down what's going wrong.

The other way of doing this is to leave off the default="elements" on 
the <namespace> element, and instead specify the namespace URI with 
ns="http://schemas.company.com/cai3g" on every other element.

You could also write a custom unmarshaller to collect all the text 
content and return it as a string.

  - Dennis

Dennis M. Sosnoski
SOA 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



Neeme Praks wrote:
> Hi,
>
> I'm quite new to JiBX and trying to implement SOAP client with JiBX, 
> Spring WS and Axis2.
>
> Anyway, cutting the long story short, I have to parse the following XML 
> fragment:
> <?xml version="1.0"?>
> <cai3g:Cai3gFault xmlns:cai3g="http://schemas.company.com/cai3g">
>    <cai3g:faultcode>3004</cai3g:faultcode>
>    <cai3g:faultreason>
>      <cai3g:reasonText>Invalid User ID or password</cai3g:reasonText>
>    </cai3g:faultreason>
>    <cai3g:faultrole>Invalid User ID or password (role)</cai3g:faultrole>
>    <cai3g:details>
>      <detail>Invalid details</detail>
>    </cai3g:details>
> </cai3g:Cai3gFault>
>
> Otherwise this is easy, expect for the fact that <cai3g:details> element 
> contains another element that is in the default namespace (no namespace).
>
> How can I handle such a thing with JiBX? I have the following binding:
> <?xml version="1.0" encoding="UTF-8"?>
> <binding xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation="binding.xsd"
> 	value-style="element">
>
> 	<namespace uri="http://schemas.company.com/cai3g" prefix="cai3g" 
> default="all"/>
>
> 	<mapping name="Cai3gFault" 
> class="com.company.cai3g.client.ProvisioningFailedException"
> 			factory="com.company.cai3g.client.model.ModelFactory.fault" 
> ordered="false" flexible="true">
> 		<value name="faultcode" field="code"/>
> 		<structure name="faultreason" usage="optional">
> 			<value name="reasonText" field="reason"/>
> 		</structure>
> 		<value name="faultrole" field="role" usage="optional"/>
> 		<!-- TODO figure out how to get also details -->
> 	</mapping>
>
> </binding>
>
> Everything else works, except for the details parsing part (I have a 
> "details" field on the exception).
>
> If I use
> 		<structure name="details" usage="optional">
> 			<value name="detail" field="details"/>
> 		</structure>
> then JiBX expects <detail> element also to be in CAI3G namespace 
> (correctly).
>
> I also tried to use
> 		<structure name="details" usage="optional">
> 			<value name="detail" field="details" ns=""/>
> 		</structure>
> but still JiBX expects <detail> element to be in CAI3G namespace.
>
> Is there some way I can instruct JiBX to use no namespace, even if 
> default namespace has been defined at root level in binding.xml?
>
> Or maybe there is some way I can tell to JiBX: ignore all XML elements 
> and just collect all text from this node and child nodes and put it in 
> some field (of type String)?
>
> Rgds,
> Neeme
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic