<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<batch-execution>
<insert out-identifier="employee" return-object="true" entry-point="DEFAULT">
<fact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="employee">
<name>Rajashekhar</name>
<age>21</age>
</fact>
</insert>
<fire-all-rules></fire-all-rules>
</batch-execution>
现在我得到的输出如上所述,但我想要像下面那样输出
<batch-execution>
<insert out-identifier="employee" return-object="true"
entry-point="DEFAULT">
<com.practise.Employee>
<name>Rajashekhar</name>
<age>21</age>
</com.practise.Employee>
</insert>
<fire-all-rules />
</batch-execution>
我的Jaxb课程
Request.java
@XmlRootElement(name = "batch-execution")
@XmlAccessorType(XmlAccessType.FIELD)
public class Request implements Serializable {
@XmlElement(name = "insert")
private List<Insert> insert;
@XmlElement(name = "fire-all-rules",nillable=true)
private String fireAllRules = "";
.
..
setters and getter
Insert.java
@XmlAccessorType(XmlAccessType.FIELD)
public class Insert {
@XmlAttribute(name = "out-identifier", required = true)
private String outIdentifier;
@XmlAttribute(name = "return-object")
private boolean returnObject;
@XmlAttribute(name = "entry-point")
private String entryPoint;
private Object fact;
.
.
setters and gettes
com.practise.Employee.java
@XmlRootElement(name="kewill.com.kewill.practoise.Employee")
@XmlAccessorType(XmlAccessType.FIELD)
public class Employee implements java.io.Serializable
{
static final long serialVersionUID = 1L;
@org.kie.api.definition.type.Label("Name")
private java.lang.String name;
@org.kie.api.definition.type.Label("Id")
private java.lang.Integer id;
@org.kie.api.definition.type.Label("Age")
private int age;
@org.kie.api.definition.type.Label(value = "valid")
private java.lang.Boolean valid;
.
. setters and getters
我认为可以通过xtream api但我想使用JAXB请在jaxb中提供解决方案。
答案 0 :(得分:0)
在Insert.java中
为
添加了注释private Object fact;
作为
@XmlAnyElement(lax = true)
private Object fact;
现在它正在给出预期的输出。