Hi Thomas,

The ICharacterEscaper approach would work for marshalling out a string 
containing markup, but wouldn't help with unmarshalling. The problem 
here is that there's no way to tell the parser to just treat the content 
of an element (<text>, in this case) as a text blob. The parser will 
*always* insist on parsing out the individual elements, and there's 
nothing JiBX can do to avoid this.

The easiest way of dealing with this type of arbitrary (but well-formed) 
content is generally to use a DOM representation. The JiBX extras 
classes include marshaller/unmarshallers for DOM and a couple of 
alternatives (JDOM and dom4j). Once you have the content in the form of 
a DOM, you can work with it directly or use an empty 
javax.xml.transform.Transformer to convert it to text.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Thomas Jones-Low wrote:
> Nick Stolwijk wrote:
>   
>> I have the following XML structure to work with:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <document>
>>     <content>
>>         <section>
>>             <text>
>>                 <html>
>>                     <body>
>>                         <p>This is a test<em>item.</em></p>
>>                     </body>
>>                 </html>
>>             </text>
>>             <subtitle>subtitel</subtitle>
>>         </section>
>>     </content>
>> </document>
>>
>> And a Java class with a property name 'text'. After unmarshalling I want 
>> this property to contain all text within the body tag (so including the 
>> elements). Do I need to write a custom unmarshaller for this or is there 
>> already something which does this?
>>
>>     
>
>       Looking back through the list archives, Kees de Kooter implemented an 
> ICharacterEscaper class to write the literal string
> to the output stream. This would work better than my solution of 
> modifying the JiBX Code.
>
>   


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

Reply via email to