Hi all,

I'm serializing java objects to a predefined XML message format that
requires certain predefined attribute values on some elements.  In essence
what we would call literals in the java world.  For example, in this
snippet the "current", "previous", "1" and "2" attributes:

<candidate>
    <address type="current">
        <street line="1"></street>
        <street line="2"></street>
        <city></city>
        <state></state>
        <zip></zip>
    </address>
    <address type="previous">
        <street line="1"></street>
        <street line="2"></street>
        <city></city>
        <state></state>
        <zip></zip>
    </address>
</candidate>

I was trying to kludge it by setting up an instance variable with the
necessary string ("current", "previous", "1", "2") on the object solely
for the purpose of being able to map it to the attribute, like so:

    public String currentString = "current" ;
    public String getCurrentString() {
        return currentString ;
    }
    public String setCurrentString(String currentString) {
        this.currentString = currentString ;
    }

This approach does not appear to work.  The attribute doesn't show up, and
since both sets of addresses are mapped under the <address> tag, it just
lumps all of the elements together in one big <address> tag set.

Additionally, I need some of these values multiple times, and it appears
Castor doesn't like to repeat an instance variable more than once in a
given XML output:

org.exolab.castor.mapping.MappingException: The field foo appears twice in
the descriptor for com.foo.bar

Obviously I can just define a currentString1, currentString2, etc, but
this is getting silly.  And in any event, this kludge doesn't actually
work.

Is there a way to do this?

Steven J. Owens
[EMAIL PROTECTED]


-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to