Would it be possible to bind it with jibx if I had
only 2 types of <x>
element?
Something like:
<?xml version="1.0" encoding="UTF-8"?>
<binding>
  <mapping name="y" class="y">
         <value name="y1" field="y1"/>
         <value name="y2" field="y2"/>
         <value name="y3" field="y3"/>
    <structure name="x" field="x" usage="optional">
      <value name="a" field="a"/>
        ...
    </structure>
    <structure name="x1" field="x1" usage="optional">
      <value name="a1" field="a1"/>
        ...
    </structure>
  </mapping>
</binding>


<y>
<y1></y1>
<y2></y2>
<y3></y3>
<x1>
        <a1></a1>
        ....    
</x1>
</y>

Or:

<y>
<y1></y1>
<y2></y2>
<y3></y3>
<x>
        <a></a>
        ....    
</x>
</y>

Thanks!

-----Original Message-----
From: Dennis Sosnoski [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 16, 2004 11:15 AM
To: Robert Augustyn
Cc: [EMAIL PROTECTED]
Subject: Re: [jibx-users] How to bind this?


That's a lot more difficult than you might expect
(using JiBX, or any 
other form of XML processing I'm aware of). The
problem is that JiBX is 
using a parser for reading the data from the document,
and parsers don't

allow you to just suddenly start reading raw text
(tags and all). It 
would be possible to do this with a custom
unmarshaller that would 
basically take the parsed XML and turn it back into a
text string, but 
even once this was done you'd have no way to include
this directly in a 
marshalled output.

A better solution may be to use the DOM or dom4j
marshaller/unmarshaller

support in beta 3a. These let you convert the <y>
element to a tree of 
component objects you can access using the standard
DOM or dom4j APIs. 
If you want to just get the XML text as a String, I
think the dom4j 
asXML() method will return it. Doing it this way also
means it'll 
marshal back out properly, if that's a concern.

  - Dennis

Robert Augustyn wrote:

>Hi,
>I have finally get going with this stuff and it looks
>good but I have
>run into another challenge and I am not quite sure
how
>to solve it,
>anything I tried did not seem to work, but I think
>should be possible :)
>
>How do you bind scenario when <y> element contains
>another xml document
>of unknown format which we want to bind to a single
>String field in an
>object?
>Thanks for taking the time.
>robert
>
><y>
>       <x>
>               <a>
>               </a>
>               ....    
>       </x>
></y>
>
>Or:
>
><y>
>       <x1>
>               <a1>
>               </a1>
>               ....    
>       </x1>
></y>
>
>  
>




        
                
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to