Thanks Eitan and Dennis.  This is working well with one exception...   It
looks like thw whitespace and newlines around the comment text is not being
trimmed.  So when this is parsed...

<Comments xml:lang="en-US">
   <Attachment>
      <URL>cid: [EMAIL PROTECTED]</URL>
   </Attachment>
   Anything well formed in XML.
</Comments>

The value for commentText includes the newline and whitespace.  Shouldn't
the whitespace be trimmed?  Is there any way to control this behavior in the
mapping?


Thanks!!
Norm

--
Norm Deane
MIS Consultant
Vanderbilt University
(615) 322-7855
[EMAIL PROTECTED]

 
-----Original Message-----
From: Eitan Suez [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 30, 2004 3:17 PM
To: [EMAIL PROTECTED]
Cc: jibx-list
Subject: Re: [Re: [jibx-users] [jibx]Mixed Element Binding]


oops, i didn't read your message through to the end..

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



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to