java - JAXB Moxy Element inside Text Content -


i have un-/marshall following snippet

    <para sizeinfoid="sizeinfo2" styleid="mono">franz jagt im komplett verwahrlosten <protectedtext>taxi</protectedtext> quer durch bayern.</para> 

my java model looks this

import javax.xml.bind.annotation.xmlattribute; import javax.xml.bind.annotation.xmlrootelement; import javax.xml.bind.annotation.xmltransient; import javax.xml.bind.annotation.xmltype; import javax.xml.bind.annotation.xmlvalue;  @xmltype(proporder = { acrossparagraph.xml_id, acrossparagraph.xml_style_id, acrossparagraph.xml_sizeinfo_id, acrossparagraph.xml_comment, acrossparagraph.xml_content }) @xmlrootelement(name = acrossparagraph.xml_root_tag) public class acrossparagraph {      public static final string xml_root_tag = "para";     public static final string xml_id = "id";     public static final string xml_style_id = "styleid";     public static final string xml_sizeinfo_id = "sizeinfoid";     public static final string xml_comment = "comment";     public static final string xml_content = "content";      private string id;     private string styleid;     private string sizeinfoid;     private string comment;     private string content;      @xmlattribute(name = acrossparagraph.xml_id)     public string getid() {         return id;     }      public void setid(string id) {         this.id = id;     }      @xmlattribute(name = acrossparagraph.xml_style_id)     public string getstyleid() {         return styleid;     }      public void setstyleid(string styleid) {         this.styleid = styleid;     }      @xmltransient     public void setstyleid(acrossstyle style) {         this.styleid = style.getid();     }      @xmlattribute(name = acrossparagraph.xml_sizeinfo_id)     public string getsizeinfoid() {         return sizeinfoid;     }      public void setsizeinfoid(string sizeinfoid) {         this.sizeinfoid = sizeinfoid;     }      @xmltransient     public void setsizeinfoid(acrosssize size) {         this.sizeinfoid = size.getid();     }      @xmlattribute(name = acrossparagraph.xml_comment)     public string getcomment() {         return comment;     }      public void setcomment(string comment) {         this.comment = comment;     }      @xmlvalue     public string getcontent() {         return content;     }      public void setcontent(string content) {         this.content = content;     }  } 

without inner protectedtext tag working, don't know how map inner element.

i have read xmlanyelement annotation havn't found example mapping this.

any ideas?

best regards, pascal

create new class protectedtext element:

@xmlrootelement(name = "protectedtext") class protectedtext implements serializable{     @xmlvalue     public string value; } 

now change content property in acrossparagraph below:

private list<serializable> content;  @xmlelementref(name = "protectedtext", type = protectedtext.class) @xmlmixed public list<serializable> getcontent(){     return content; }  public void setcontent(list<serializable> content){     this.content = content; } 

when unmarshal content list contains mix of string , protectedtext


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -