Hi,
the solution is to use a custom marshaller/unmarshaller, f.e. the
DomFragmentMapper
Here's the extended example7 of the binding-tutorial:
Java:
=====
package example7;
import org.w3c.dom.DocumentFragment;
public class Customer {
public Person person;
public String street;
public String city;
public String state;
public Integer zip;
public String inst;
public String phone;
public DocumentFragment instructions;
}
Binding:
========
<binding>
<mapping name="customer" class="example7.Customer">
<value name="street" field="street"/>
<value name="city" field="city"/>
<value name="state" field="state"/>
<value name="zip" field="zip"/>
<structure name="instructions">
<structure field="instructions"
marshaller="org.jibx.extras.DomFragmentMapper"
unmarshaller="org.jibx.extras.DomFragmentMapper" />
</structure>
<value name="phone" field="phone"/>
</mapping>
</binding>
Data:
=====
<customer>
<street>12345 Happy Lane</street>
<city>Plunk</city>
<state>WA</state>
<zip>98059</zip>
<instructions>
<!-- content skipped when unmarshalled -->
<p>Leave package behind bushes to <b>left</b>
of door</p>
<!-- always marshalled as empty -->
</instructions>
<phone>888.555.1234</phone>
</customer>
Thanks,
Markus
========================================================================
======
in example7 of the binding tutorial, there's a xml like:
<customer>
<street>12345 Happy Lane</street>
<city>Plunk</city>
<state>WA</state>
<zip>98059</zip>
<instructions>
<!-- content skipped when unmarshalled -->
<p>Leave package behind bushes to <b>left</b>
of door</p>
<!-- always marshalled as empty -->
</instructions>
<phone>888.555.1234</phone>
</customer>
if I marshall the object, I would like to write the follwing element
with it's content to the xml file (comments are not importent):
<instructions>
<!-- content skipped when unmarshalled -->
<p>Leave package behind bushes to <b>left</b>
of door</p>
<!-- always marshalled as empty -->
</instructions>
is there someting like any in xml-schema in the binding-defintion of
jibx ? f.e. i don't know the sub-content of an element (f.e. because ist
structure is too complex) but however I want to write it to my
marshalled xml-file.
for my tries I get the following exception:
org.jibx.runtime.JiBXException: Expected "instructions" end tag, found
"p" start tag (line 7, col 4)
at
org.jibx.runtime.impl.UnmarshallingContext.parseContentText(Unmarshallin
gContext.java:956)
at
org.jibx.runtime.impl.UnmarshallingContext.parseElementText(Unmarshallin
gContext.java:1005)
Thanks for any advice,
Markus
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users