jaxb

how to create customized marshalled output from JAXB?

一笑奈何 提交于 2020-01-16 11:47:28
问题 I don't want to use XML file created by JAXB marshaller, can I customize it, so that i would give a preferrable format to marshal objects? 回答1: You can take JAXB's XML output and process it in a way you like, to achieve an alternative output. XSLT, DOM, or something else... XML is perfect to be further transformed! 回答2: jaxb is related to XML ... if you need to customize the xml then you can use the Jaxb annotations http://java.sun.com/javaee/5/docs/api/javax/xml/bind/annotation/package

JAXB Marshal and Unmarshal Map to/from <key>value</key>

心已入冬 提交于 2020-01-16 05:06:09
问题 I'm trying to marshal and unmarshal Map to/from value pairs. I can marshal the object successfully, however, I cannot unmarshal it from the xml. The unmarshal result is the key exist in the Map, however, its value is null. Here's the model I want to marshal and unmarshal: import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import

JAXB - Parse element into string

帅比萌擦擦* 提交于 2020-01-16 04:33:08
问题 Is there a way to parse part of an XML message into a String keeping it in XML format? Example... <person> <name>John Doe</name> <age>24</age> <address> <street>bailey</street> <city>boston</city> </address> </person> public class Person { @XmlElement private NameClass name; @XmlElement private int age; @XmlElement private String address; ... } public class NameClass { ... } Where I want the entire address element to be kept in XML format and parsed as a String. 回答1: You can use

Dynamic JAXB support to convert XML to JSON

你离开我真会死。 提交于 2020-01-16 03:25:50
问题 I am using eclipse link(v2.5.0) Dynamic JAXB to convert XML to JSON and viceversa. customer.xsd <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="address" type="address"/> <xs:element name="customer" type="customer"/> <xs:complexType name="address"> <xs:sequence> <xs:element name="city" type="xs:string" minOccurs="0"/> <xs:element name="street" type="xs:string" minOccurs="0"/> <xs:element name="type"

XmlIDREF is not working

我怕爱的太早我们不能终老 提交于 2020-01-16 00:51:13
问题 using JAXB 2.2.5b, and having @XmlSeeAlso({BeanView.class, ViewField.class, ViewPanel.class, ViewTab.class, ElementRef.class}) @XmlRootElement public abstract class ViewElement { @XmlID @XmlAttribute public String getId() { return id; } } @XmlRootElement(name="ref") public class ElementRef extends ViewElement{ private ViewElement target; @XmlElement @XmlIDREF public ViewElement getTarget() { return target; } public void setTarget(ViewElement target) { this.target = target; } } Many class

Prevent generation of duplicate classes from XSDs without namespaces

走远了吗. 提交于 2020-01-15 17:36:02
问题 I am currently implementing functionally for our Netbeans Platform application using classes generated by JAXB using the Mojo Maven plugin 'jaxb2-maven-plugin'. Unfortunately the creation of the XSD files is not in my hands and they are confidential. I am trying to provide a minimal running example to further demonstrate this but for now I hope that somebody can push me in the right direction solely from my description. We have many XSD files and got a few additions in the last weeks. Two of

Prevent generation of duplicate classes from XSDs without namespaces

白昼怎懂夜的黑 提交于 2020-01-15 17:35:42
问题 I am currently implementing functionally for our Netbeans Platform application using classes generated by JAXB using the Mojo Maven plugin 'jaxb2-maven-plugin'. Unfortunately the creation of the XSD files is not in my hands and they are confidential. I am trying to provide a minimal running example to further demonstrate this but for now I hope that somebody can push me in the right direction solely from my description. We have many XSD files and got a few additions in the last weeks. Two of

Prevent generation of duplicate classes from XSDs without namespaces

ぐ巨炮叔叔 提交于 2020-01-15 17:35:33
问题 I am currently implementing functionally for our Netbeans Platform application using classes generated by JAXB using the Mojo Maven plugin 'jaxb2-maven-plugin'. Unfortunately the creation of the XSD files is not in my hands and they are confidential. I am trying to provide a minimal running example to further demonstrate this but for now I hope that somebody can push me in the right direction solely from my description. We have many XSD files and got a few additions in the last weeks. Two of

ObjectFactory methods generated by jaxb

假装没事ソ 提交于 2020-01-15 15:44:41
问题 I am trying to make web services but there are two situations I am getting. There are two types of xsd file 1st one is: <xsd:element name="signupRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="email" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element <xsd:element name="signupResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="signup" type="tns:Signup"/> </xsd:sequence> </xsd:complexType> </xsd:element>

ObjectFactory methods generated by jaxb

我只是一个虾纸丫 提交于 2020-01-15 15:41:33
问题 I am trying to make web services but there are two situations I am getting. There are two types of xsd file 1st one is: <xsd:element name="signupRequest"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="email" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element <xsd:element name="signupResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="signup" type="tns:Signup"/> </xsd:sequence> </xsd:complexType> </xsd:element>