java - Jaxb marshalling strips out a required tag -


i'm trying produce following xml output snippet :

<benefits>    <notes>benefits note</notes>    <detail xmlns:ns2="http://www.w3.org/1999/xhtml">       **<body>**         <p style="font-family:'myriad pro';text-decoration:none">description 2</p>       **</body>**        </detail> </benefits> 

here xml annotated class

@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "descriptiontype", proporder = {     "notes",     "detail" }) public class descriptiontype {      @xmlelement(required = true)     protected string notes;     @xmljavatypeadapter(value=cdataadapter.class)     @xmlelement(required = true)     protected object detail;      public string getnotes() {         return notes;     }      public void setnotes(string value) {         this.notes = value;     }     public object getdetail() {         return detail;     }     public void setdetail(object value) {         this.detail = value;     } } 

if put breakpoint before marshalling , inspect "detail" variable instance of class descriptiontype contains following

string type "<?xml version="1.0" encoding="utf-8" standalone="no"?><body xmlns="http://www.w3.org/1999/xhtml"><p style="font-family:'myriad pro'">description 1</p>                         </body>" 

that when try marshal xml convert document element in custom adapter so:

 element e =  documentbuilderfactory.newinstance().newdocumentbuilder().            parse(new bytearrayinputstream(((string)s).getbytes())).getdocumentelement();    return e; 

the output becomes:

<benefits>    <notes>benefits note</notes>    <detail xmlns:ns2="http://www.w3.org/1999/xhtml">        <p style="font-family:'myriad pro';text-decoration:none">description 2</p>    </detail> </benefits> 

the question? how can make preserve tag? much


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -