Hi,

This is about some sort of a feature request.  In short:

how to use external parameters in a binding file (passed when invoking
IMarshallingContext.marshalDocument()).  This would correspond to adding a
method IMarshallingContext.marshalDocument(Object root, Map<String, String>
parameters).  The binding file would then contain something like <structure
name="history" get-method="getHistory($sinceDate$)" />, where sinceDate is a
key in the parameters Map used in the above marshalDocument method .  I am
aware of the fact that the get-method currently is a no-argument method.  I
guess that a skilled developer (I am a lousy coder and have difficulties
understanding the JiBX source-code) could add this functionality...  Or am I
wrong?

Let me elaborate on this, in case I wasn't able to make my point clear.
I'll give an example to show the real problem which is at the origin of my
request.  Perhaps the above feature request is not really necessary and
there is a workaround I am not aware of.

After using JiBX (occasionaly) for more than 2 years (I have to admit I
still use 1.0.1) and after reading the tutorials and instructions etc... I
still have not found an elegant answer to the above question (see
Subject:).  I realize that one can fiddle around with adding a field to the
rootobject and setting the parameter in the rootobject could be a solution,
but I would like to avoid that method.

Let me slightly elaborate on this: consider a model where you have two
classes: Person and LogEntry.  There is a one-to-many mapping between both.
But moreover, I do not only have a method Person.getHistory(), but also a
Person.getHistory(sinceDate) (see below).  In my current application, JiBX
does not allow me to invoke the Person.getHistory(sinceDate) method for
generating the LogEntry-childElements.  I actually would like to specify
parameters when I perform a marshalDocument.  For instance, when one applies
a XSLT-transformation upon an XML-document, you can add parameters to be
used by the stylesheet.  Is it possible to do something similar with JiBX?

Classes (simplyfied):

public class LogEntry{
    private Date date;
    private String msg;
    [...]
}

public class Person{
    private String name;
    private List<LogEntry> history;
    public String getName(){return name;}
    public List<LogEntry> getHistory(){ return history;}
    public List<LogEntry> getHistory(Date sinceDate){
        //only return LogEntry-instances which have date > sinceDate;
    }
    [...]
}

Desired output:

<activities>
    <name>John Doe</name>
    <history>
        <entry date="20070201">subscribe</entry>
        <entry date="20070201">change password</entry>
        <entry date="20070204">submit question</entry>
        <entry date="20070305">answer question</entry>
        <entry date="20070309">unsubscribe</entry>
    </history>
</activities>

The history-element in the above XML-document should only contain the
entries which occurred after a given date (thus, I would like to be able to
use the get-method "getHistory(Date sinceDate) when I generate the
XML-document with the activities for person John Doe).

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

Reply via email to