Hey William,
 
I'm a little late to the conversation but I thought I would post so that I can 
at least outline how I was able to get this to work. Firstly, in our system we 
have many different "views" of an object, some which have upwards of 9 
different representations. 
 
With that said, how we do it, is first we generate a different binding file for 
each "view" in our system, so after our binding generation we end up with 24 
binding files which follow the format of:
 
    binding-create.xml
    binding-fill.xml
    binding-id.xml
    ...
 
Where "create", "fill" and "id" are the names that refer to each binding. We 
then have an ant task in our system which looks like:
 
        <bind verbose="${jibx.verbose}" load="true">
            <bindingfileset 
dir="${sw.basedir}/${project.tools}/${build.jibx}/@{project}">
              <include name="*.xml"/>
            </bindingfileset>
            <classpath>
              <path id="@{project}.classpath"/>
              <path id="[EMAIL PROTECTED]" />
              <pathelement path="${sw.basedir}/cas/${build.compiled}"/>
              <pathelement path="${sw.basedir}/weblet/${build.compiled}"/>
              <pathelement path="${sw.basedir}/back/${build.compiled}"/>
              <pathelement path="${sw.basedir}/office/${build.compiled}"/>
              <pathelement path="${sw.basedir}/platform/${build.compiled}"/>
            </classpath>
          </bind>
 
The bindingfileset directive simply points to a directory containing all of the 
XML that was mentioned prior.
 
The important things to note is that the binding MUST occur at all once, we 
made this mistake at first. Following this we are able to marshal and demarshal 
each of the views into their own respective format. Not sure if this is helpful 
at all, but I can verify that it does and has been working using this type of 
structure for about a year now. Let me know if I can clarify anything.
 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of William Surowiec
Sent: Monday, November 26, 2007 1:56 PM
To: JiBX users
Subject: Re: [jibx-users] best practice for multiple views of the same java 
object


Hmmm, I cannot reproduce what I thought was success. I am reporting so another 
does not think (on the basis of my previous email) it works for me and if it is 
not working for them then it must be them.

I cannot get two bindings defined on the same class with each available at 
runtime.

I can confirm the following:

If I run the ant bind task twice, 
  with the xml in the binding attribute pointing to the same java class each 
time, 
  then the last of the two definitions survives - the first is not found at 
runtime.

If I run the ant task once, 
  with the the xml in the binding attribute containing two binding elements, 
  then the first is found at runtime, the second is not.

If I run the ant bind task once,
  with the xml in the binding attribute only including two other binding files,
  then the ant task dies with a 
  [bind] java.lang.NullPointerException
     [bind]     at 
org.jibx.binding.model.NameAttributes.equals(NameAttributes.java:184)

I thought I tested this -  late night testing seems not to be what it appeared 
to be.

(Even now, after several daylight hours of twisting and turning I am no longer 
sure of even the above.)

Maybe it is that dratted Grinch pilfering gifts.

I will report any discoveries (including convicting the usual suspects (me.))

Bill

Günther Wieser wrote: 

        hi bill, 

        good to hear that you solved your issues!

        regarding the track-source feature: this can be left out if you don't 
need the functionality, see the first chapter in
        http://jibx.sourceforge.net/tutorial/binding-advanced.html

        br,
        günther

        Am 20.11.2007 um 06:05 schrieb William Surowiec:


                Gunther,
                
                Thank you, it is now working using the second method you 
indicated. It was not obvious to me that I could have multiple bindings in one 
file. So, my binding.xml file is structured something like:
                
                <binding name="bindingReportInput" direction="input" 
track-source="true">
                    <mapping name="report"  class="xxx.Report">
                    <BIG SNIP/>
                    </mapping>
                </binding>
                <binding name="bindingReportOutput1" direction="output" 
track-source="true">
                    <mapping name="report" class="xxx.Report">
                    <BIG SNIP/>
                    </mapping>
                </binding>
                
                I am not sure if the track-source has any meaning for the 
output direction, but nothing complained when simple cut and paste left it 
unintentionally in there. I will remove it (and choose better names for things 
as we get more serious.)
                
                Really nice. Great tool.
                
                Thank you again for the help (the "other" ingredient making for 
a great tool),
                
                Bill
                
                Günther Wieser wrote: 

                        hi bill, 

                        there are two ways to accomplish that:
                        first, if your input and output binding will be the 
same in each situation, you can use different mappings by specifying the 
direction="output" or direction="input" attribute in the binding element, see
                        
http://jibx.sourceforge.net/tutorial/binding-advanced.html

                        second, you can use named bindings. you can specify a 
name in the binding element, and in your java code, you can specify which named 
binding you want to use. this allows you to use as many different bindings as 
you like or need.
                        see the binding definition at 
http://jibx.sourceforge.net/details/binding-element.html for more details on 
the attribute "name". i think there is also some more detailed explanation in 
the tutorial, but i couldn't find it now.

                        br,
                        günther

                        Am 19.11.2007 um 22:16 schrieb William Surowiec:


                                Hi, 
                                
                                I've recently started using JibX - really 
useful, thank you. 
                                
                                But, of course, I have a question. I sense 
there may be several ways to accomplish what I wish to do and I would 
appreciate guidance on the "best practice" way. Here is what I would like to 
accomplish: 
                                
                                I have a complex, custom Java object. I receive 
an xml representation of it (actually a subset of it.) I can parse the subset 
without a problem. I now wish to produce another xml representation of it (same 
object) but publishing different facets of it. Structurally the resultant xml 
would look different than the input xml: meta data inserted, aggregation 
performed, some field elided. 
                                
                                In this specific situation, it makes sense to 
maintain a single object with multiple views. Is there a "best practice" jibx 
approach? 
                                
                                Thanks, 
                                
                                Bill 
                                
                                
                                
                                
                                
-------------------------------------------------------------------------
                                This SF.net email is sponsored by: Microsoft
                                Defy all challenges. Microsoft(R) Visual Studio 
2005.
                                
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
                                jibx-users mailing list
                                jibx-users@lists.sourceforge.net
                                
https://lists.sourceforge.net/lists/listinfo/jibx-users
                                


                        


                        -- 
                        Günther Wieser
                        creative-it
                        Guglgasse 6/1/11/1
                        A-1110 Wien
                        [EMAIL PROTECTED]
                        http://www.creative-it.com



                        
________________________________


                        
-------------------------------------------------------------------------
                        This SF.net email is sponsored by: Microsoft
                        Defy all challenges. Microsoft(R) Visual Studio 2005.
                        http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
                        
________________________________


                        _______________________________________________
                        jibx-users mailing list
                        jibx-users@lists.sourceforge.net
                        https://lists.sourceforge.net/lists/listinfo/jibx-users
                          

                
-------------------------------------------------------------------------
                This SF.net email is sponsored by: Microsoft
                Defy all challenges. Microsoft(R) Visual Studio 2005.
                
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
                jibx-users mailing list
                jibx-users@lists.sourceforge.net
                https://lists.sourceforge.net/lists/listinfo/jibx-users
                


        


        -- 
        Günther Wieser
        creative-it
        Guglgasse 6/1/11/1
        A-1110 Wien
        [EMAIL PROTECTED]
        http://www.creative-it.com



        
________________________________


        
-------------------------------------------------------------------------
        This SF.net email is sponsored by: Microsoft
        Defy all challenges. Microsoft(R) Visual Studio 2005.
        http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
        
________________________________


        _______________________________________________
        jibx-users mailing list
        jibx-users@lists.sourceforge.net
        https://lists.sourceforge.net/lists/listinfo/jibx-users
          

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to