jaxb

ObjectFactory methods generated by jaxb

核能气质少年 提交于 2020-01-15 15:41:00
问题 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>

XSD sequence compile to different lists

被刻印的时光 ゝ 提交于 2020-01-15 12:33:54
问题 I have XSD schema like this: <xs:complexType name="Element" abstract="true"> <xs:sequence maxOccurs="unbounded"> <xs:element name="resistor" type="vs:Resistor" maxOccurs="unbounded"/> <xs:element name="capacitor" type="vs:Capacitor" maxOccurs="unbounded"/> <xs:element name="inductor" type="vs:Inductor" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> And when I process this schema through JAXB I get a field like this: @XmlElements({ @XmlElement(name = "resistor", required = true, type

XSD sequence compile to different lists

人走茶凉 提交于 2020-01-15 12:33:05
问题 I have XSD schema like this: <xs:complexType name="Element" abstract="true"> <xs:sequence maxOccurs="unbounded"> <xs:element name="resistor" type="vs:Resistor" maxOccurs="unbounded"/> <xs:element name="capacitor" type="vs:Capacitor" maxOccurs="unbounded"/> <xs:element name="inductor" type="vs:Inductor" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> And when I process this schema through JAXB I get a field like this: @XmlElements({ @XmlElement(name = "resistor", required = true, type

XSD sequence compile to different lists

主宰稳场 提交于 2020-01-15 12:32:21
问题 I have XSD schema like this: <xs:complexType name="Element" abstract="true"> <xs:sequence maxOccurs="unbounded"> <xs:element name="resistor" type="vs:Resistor" maxOccurs="unbounded"/> <xs:element name="capacitor" type="vs:Capacitor" maxOccurs="unbounded"/> <xs:element name="inductor" type="vs:Inductor" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> And when I process this schema through JAXB I get a field like this: @XmlElements({ @XmlElement(name = "resistor", required = true, type

DomHandler to capture text for multiple records

霸气de小男生 提交于 2020-01-15 11:14:14
问题 I am attempting to use @XmlAnyElement with DomHandler to capture the unparsed text within a particular field like in this example from Blaise Doughan. But when I attempt to parse multiple customers the contents of bio fields from all previous records continue to be sent to my DomHandler! Here is the example document I am trying to parse: <?xml version="1.0" encoding="UTF-8"?> <customers> <customer> <name>Jane Doe</name> <bio> <html>Jane's bio</html> </bio> </customer> <customer> <name>John

Jersey - MessageBodyWriter not found application/xml ArrayList (with jersey-jaxb in war)

本秂侑毒 提交于 2020-01-15 10:56:07
问题 I have a Jersey controller that is returning a List<MyPojo> (it is actually returning an ArrayList . My pom includes jersey-server and so I am automatically getting jersey-media-jaxb and I have verified that my war does contain that dependency. The endpoint is marked with: @Produces(value={MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) When I hit it with no accept specified (or with application/json ) I get back JSON with no issues. But when I specify 'accept=application/xml` I get:

Jersey - MessageBodyWriter not found application/xml ArrayList (with jersey-jaxb in war)

一曲冷凌霜 提交于 2020-01-15 10:56:05
问题 I have a Jersey controller that is returning a List<MyPojo> (it is actually returning an ArrayList . My pom includes jersey-server and so I am automatically getting jersey-media-jaxb and I have verified that my war does contain that dependency. The endpoint is marked with: @Produces(value={MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) When I hit it with no accept specified (or with application/json ) I get back JSON with no issues. But when I specify 'accept=application/xml` I get:

JAXB unmarshalling not tolerating whitespace around token enumerations

青春壹個敷衍的年華 提交于 2020-01-15 09:13:51
问题 JAXB 2 (Oracle / Metro version 2.2.7 and I suspect others as well) doesn't seem to tolerate whitespace around values in enumeration elements. Minimal example follows. Both xmllint and Xerces validate the instance against the schema. The puzzling think is that JAXB validation doesn't complain but returns null when trying to access the value. How can I configure it to return the value properly? update: I 've tried associating an XmlAdapter to trim the strings, as suggested here, but the result

JAXB unmarshalling not tolerating whitespace around token enumerations

那年仲夏 提交于 2020-01-15 09:13:00
问题 JAXB 2 (Oracle / Metro version 2.2.7 and I suspect others as well) doesn't seem to tolerate whitespace around values in enumeration elements. Minimal example follows. Both xmllint and Xerces validate the instance against the schema. The puzzling think is that JAXB validation doesn't complain but returns null when trying to access the value. How can I configure it to return the value properly? update: I 've tried associating an XmlAdapter to trim the strings, as suggested here, but the result

jaxbcontext generating incomplete schemas?

这一生的挚爱 提交于 2020-01-15 08:52:06
问题 I've run into a strange problem with JAXB. I've used xjc to generate my java classes from my XSD and all looks good. If I use schemagen, it produces a proper schema that matches my original xsd. However, if I use JAXBContext.generateSchema(), then the generated schema is incomplete. I'm using Oracle Java 1.6.0_29 and jaxb-2.2.4-1.jar as the implementation. I'm enclosing the java code (which generates the schema), and the xsd below as well as the output of the jaxb call.