jaxb2

@XmlJavaTypeAdapter not calling TypeAdapter

筅森魡賤 提交于 2019-12-12 01:38:14
问题 I have a fixed XML structure that is already utilised by other applications. Some of these are third party, so changing the XML is not an option. The XML contains a section which I am struggling to unmarshal. Below is a cut down version. This element is a child of other elements. <premium> <allowInstalments>true</allowInstalments> <annualPremium>2964.23</annualPremium> <!-- other various elements --> <calcElement partname="driver"> <driverXs>300.00</driverXs> <seq>1</seq> </calcElement>

Adding annotations to package-info generated by JAXB

余生长醉 提交于 2019-12-11 12:34:28
问题 I have been using annox to add annotations on my jaxb-generated classes (through bindings files) but I can't find a way to add annotations directly on the package (package-info.java). I've been trying to do something like this in my bindings.xml: <jaxb:schemaBindings> <jaxb:package name="my.package"> <annox:annotate> <annox:annotate annox:class="my.Annotation" /> </annox:annotate> </jaxb:package> </jaxb:schemaBindings> but jaxb complains that annox:annotate is not expected to be there. Is

jaxb2 simplify plugin binding issue

醉酒当歌 提交于 2019-12-11 11:56:07
问题 I tried to use JAXB2 simplify plugin using the XJC 2.2.4. D:\>xjc -d . -extension -p org.my.space sample.xsd parsing a schema... [ERROR] Unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/simplify". Perhaps you meant "http://jaxb.dev.java.net/plugin/code-injector"? line 7 of file:/D:/sample.xsd Failed to parse a schema. sample.xsd has the declared simplify <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"

Unmarshal List to Types

浪子不回头ぞ 提交于 2019-12-11 11:52:20
问题 I have this xml <data-set> <list-property name="columns">...</list-property> <list-property name="resultSet">...</list-property> <data-set> Need to unmarshal this to object: public class DataSet { private Columns columns; private ResultSet resultSet; ... } Help me to implement that if it possible. Update What I tried to do: public class DataSet { @XmlElement("list-property") @XmlJavaTypeAdapter(DataSetListPropertyAdapter.class) private Columns columns; @XmlElement("list-property")

How do I (un)marshall a list or array as the root element with JAXB2?

筅森魡賤 提交于 2019-12-11 07:18:26
问题 I would like to marshall and unmarshall documents with JAXB2 annotations that are structured as follows: <mylist> <element /> <element /> <element /> </mylist> It's a well-formed XML document, which represents a sequence of elements. The obvious thing to do results in a root element of some kind containing the list: @XmlRootElement(name="container") public class Container { @XmlElement @XmlElementWrapper(name="mylist") public List<Element> getElements() {...} } But then I get a document on

Reusable complexType, and xml-registry, xml-element-decl usage

你说的曾经没有我的故事 提交于 2019-12-11 06:58:35
问题 I've the below TimePeriodType <xs:simpleType name="UnitOfTimePeriodType"> <xs:restriction base="xs:token"> <xs:enumeration value="Months"/> <xs:enumeration value="Days"/> <xs:enumeration value="Years"/> </xs:restriction> </xs:simpleType> <xs:complexType name="TimePeriodType"> <xs:sequence> <xs:element name="Length" type="digit1-3"/> </xs:sequence> <xs:attribute name="unitOfLength" type="UnitOfTimePeriodType" use="optional" default="Months"/> </xs:complexType> which gets used in multiple types

How parse xml using jaxb

廉价感情. 提交于 2019-12-11 01:57:27
问题 I am new in JAXB, I want to read XML file to Java object, which is in the following format: <payTypeList> <payType>G</payType> <payType>H</payType> <payType>Y</payType> </payTypeList> Please help me how to read this type of XML. 回答1: This is your scenario import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name=

Generate source using jaxb from an xsd that is in my classpath

岁酱吖の 提交于 2019-12-10 18:17:42
问题 I'm trying to generate java classes using JAXB from a schema in my class path. For CXF I generated java classes from a wsdl in my classpath like so: <wsdlOptions> <wsdlOption> <wsdl>classpath:wsdl/MetsInterfaceService.wsdl</wsdl> </wsdlOption> </wsdlOptions> I was hoping something similar existed with JAXB. I did try using a catalog but this seems to be more in line when a schema (stored in the same maven module) imports another schema in the classpath. Any help would be appreciated! -Sal 回答1

Generate Java class based on XSD without block substitution?

社会主义新天地 提交于 2019-12-10 18:14:06
问题 I am getting below error while maven build using jaxb(maven-jaxb2-plugin) compiler A class/interface with the same name "org.somePackage.customer" is already in use. Use a class customization to resolve this conflict. at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:121) at com.sun.tools.xjc.util.CodeModelClassFactory.createClass(CodeModelClassFactory.java:82) at com.sun.tools.xjc.generator.bean.ImplStructureStrategy$1.createClasses(ImplStructureStrategy

Avoiding Compiler warnings on code generated by xjc

北战南征 提交于 2019-12-10 16:49:44
问题 My root question is how to benefit from the 'unchecked generics type' Eclipse compiler warning, but not have the list of those warnings in the Problems view polluted by noise from java classes which are generated from xsd files by xjc (via maven-jaxb2-plugin.) I've read other places that I can ignore compiler warnings per source folder and that would be great, but I don't have the authority to place the generated code it it's own source folder. :( Given my situation, my assumption is that the