oxm

Jibx - how to unmarshal/marshal tag with value and attribute?

假如想象 提交于 2019-12-21 05:22:26
问题 <stateData> <MyTag name="voltage">12</Mytag> <MyTag name="Fuel">72</Mytag> </stateData> Sorry Guys, I did not meant to be lazy. Ok Here is the question: I have xml structure with above block of xml which some tags has both value and attribute in tag notation( MyTag has value of 12 and has an attribute name). using Jibx how I can create binding schema for such case. Obviously for xml tags with only value or with attributes without tag value is normal, but when you have both of them I don't

JAXB HashMap unmappable

心不动则不痛 提交于 2019-12-18 04:09:55
问题 I want to convert a HashMap in a POJO class to XML. I tried using the XmlAdapter but it results in only the key and value pairs of the HashMap being the attributes of the XML Elements. I need the Key to be the Element itself and the value of the HashMap to be the value of the element. For instance, I need the following XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cart> <supervisor_id>555</supervisor_id> <payments> <payment sequence="1"> <amount>123.45</amount> <billing_method

JAXB-Eclipselink: Mapping abstract “getter” to XML

╄→尐↘猪︶ㄣ 提交于 2019-12-11 02:58:48
问题 I am using the EclipseLink implementation (2.3) of JAXB to map POJOs to XML and encountering a problem with following usecase: public abstract class A { public abstract Set<X> getX(); // There is no setter } public class B extends A { // Set via constructor private Set<X> x; @Override public Set<X> getX(); } I am defining the mapping itself completely in an external bindings-file, i set class A to be transient like so: <java-type name="foo.A" xml-transient="true"/> and for class B: <java-type

How to tell castor to marshall a null field to an empty tag?

99封情书 提交于 2019-12-08 02:21:59
问题 I'm marshalling an object that can have some field set to null. I'm using castor with a xml-mapping file for the configuration. The class I'm marshalling is like this: class Entity { private int id; private String name; private String description; // THIS CAN BE NULL /* ... getters and setters follow ... */ } ...and a mapping file like this: <mapping> <class name="Entity"> <field name="id" type="integer"/> <field name="name" type="string"/> <field name="description" type="string"/> </class> <

How to tell castor to marshall a null field to an empty tag?

◇◆丶佛笑我妖孽 提交于 2019-12-06 06:45:11
I'm marshalling an object that can have some field set to null. I'm using castor with a xml-mapping file for the configuration. The class I'm marshalling is like this: class Entity { private int id; private String name; private String description; // THIS CAN BE NULL /* ... getters and setters follow ... */ } ...and a mapping file like this: <mapping> <class name="Entity"> <field name="id" type="integer"/> <field name="name" type="string"/> <field name="description" type="string"/> </class> </mapping> What I'm getting at the moment if the field is null (simplified example): <entity> <id>123<

Jibx - how to unmarshal/marshal tag with value and attribute?

只谈情不闲聊 提交于 2019-12-03 16:39:23
<stateData> <MyTag name="voltage">12</Mytag> <MyTag name="Fuel">72</Mytag> </stateData> Sorry Guys, I did not meant to be lazy. Ok Here is the question: I have xml structure with above block of xml which some tags has both value and attribute in tag notation( MyTag has value of 12 and has an attribute name). using Jibx how I can create binding schema for such case. Obviously for xml tags with only value or with attributes without tag value is normal, but when you have both of them I don't know what to do. Thanks. Use <value/> element twice in your binding. Once with attribute and once with

jaxb: strange class cast exception on enum list

喜欢而已 提交于 2019-11-30 11:59:25
I am using jaxb to generate java classes from an xsd file. The xsd contains a definition of an element of which the content is a list of constants defined in the same xsd as enumeration. When the classes are generated using the JAXB reference implementation from the oracle's jdk1.7 ( v2.2.4-2 ) it is possible to iterate over the list of enums and assign them the variables of the same type. However, when the classes are generated using oracle's jdk1.8 (build 1.8.0_45-b15 - latest as of posting date) JAXB reference implementation ( v2.2.8-b130911.1802 ) it is no longer possible to assign the

Mapping XML to an object in Java

微笑、不失礼 提交于 2019-11-30 04:12:50
Suppose I have a class called Test , like this public class Test { private String testId; private String description; private String department; public Test() {} public Test(String id,String des,String dpt) { this.testId = id; this.department = dpt; this.description = des; } public String getTestId() { return testId; } public void setTestId(String testId) { this.testId = testId; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getDepartment() { return department; } public void setDepartment

jaxb: strange class cast exception on enum list

依然范特西╮ 提交于 2019-11-29 17:36:55
问题 I am using jaxb to generate java classes from an xsd file. The xsd contains a definition of an element of which the content is a list of constants defined in the same xsd as enumeration. When the classes are generated using the JAXB reference implementation from the oracle's jdk1.7 ( v2.2.4-2 ) it is possible to iterate over the list of enums and assign them the variables of the same type. However, when the classes are generated using oracle's jdk1.8 (build 1.8.0_45-b15 - latest as of posting

Mapping XML to an object in Java

℡╲_俬逩灬. 提交于 2019-11-29 01:00:47
问题 Suppose I have a class called Test , like this public class Test { private String testId; private String description; private String department; public Test() {} public Test(String id,String des,String dpt) { this.testId = id; this.department = dpt; this.description = des; } public String getTestId() { return testId; } public void setTestId(String testId) { this.testId = testId; } public String getDescription() { return description; } public void setDescription(String description) { this