i tested this so it works:
1. Foo.java:
package myexample;
public class Foo
{
String attachmentUrl;
String commentText;
public void postset()
{
System.out.println("attachmentUrl: "+attachmentUrl);
System.out.println("commentText: "+commentText);
}
}
2. binding.xml:
<binding>
<mapping name="Comment" class="myexample.Foo" post-set="postset">
<structure name="Attachment">
<value name="URL" field="attachmentUrl" />
</structure>
<value style="text" field="commentText" />
</mapping>
</binding>
3. data.xml:
<Comment>
<Attachment>
<URL>cid:[EMAIL PROTECTED]</URL>
</Attachment>
Here are my comments that go with this attachment.
</Comment>
if you unmarshal you'll see postset() output the values from data.xml..
/ eitan
On Apr 30, 2004, at 3:55 PM, Eitan Suez wrote:
hi norm,
i don't think you need to do anything special to get mixed content.
just use the style="text" attribute on whatever values you want
to end up as comments..
here's a starter binding for your example below though i didn't
take the time to actually test it..
<binding>
<mapping name="comment" class="pkgname.Comment">
<structure name="Attachment" field="attachment">
<value name="URL" field="url" />
</structure>
<value field="thecomments" style="text" />
</mapping>
</binding>
/ eitan
On Apr 30, 2004, at 1:10 PM, Norm Deane wrote:
Ok, so I found the example mapper but I still don't quite grasp how I
can implement a mapper that can handle a mixed element. From what I see
it looks like an unmarshaller is supposed to handle translating 1
element into an object which is then used to set a property on another
object. Suppose I want to take this structure...
<Comment>
<Attachment>
<URL>cid:[EMAIL PROTECTED]</URL>
</Attachment>
Here are my comments that go with this attachment.
</Comment>
and map it into this Object model...
public class Foo
{
private String attachmentUrl;
private String commentText;
}
Thanks,
Norm
From: Eitan Suez <[EMAIL PROTECTED]>
Date: April 30, 2004 10:31:01 AM CDT
To: [EMAIL PROTECTED]
Subject: Re: [jibx-users] [jibx]Mixed Element Binding
hello,
tutorial/example14/HashMapper.java is a sample marshaller
and unmarshaller. it also has accompanying documentation
in the tutorial ( see
jibx-beta3a/docs/binding-custom.html#marunmar )
thanks, eitan
On Apr 30, 2004, at 10:14 AM, Norm Deane wrote:
Has there been any work done to handle mixed element binding in JiBX?
ie.
<foo>
<bar>hello</bar>
Some more text in this element.
</foo>
I saw a post in the archive that mentioned using a custom
marshaller/unmarshaller but don't understand all that is involved.
According to the post there is supposed to be a sample marshaller and
unmarshaller but I can't find them.
Thanks,
Norm
