xjc

JAXB - XJC - influencing generated typesafe enum class and members

Hi there, When compiling the following simpleType with the XJC compile (from the JAXB package)... <xs:simpleType name="test"> <xs:annotation> <xs:appinfo> <jaxb:typesafeEnumClass/> </xs:appinfo> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="4"> <xs:annota...

No @XmlRootElement generated by JAXB

I'm trying to generate Java classes from the FpML (Finanial Products Markup Language) version 4.5. A ton of code is generated, but I cannot use it. Trying to serialize a simple document I get this: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2: unable to marshal type "org.fpml._2008.fpm...

xjc binding customization does not work in jaxb 2.1.3. It works in jaxb 2.0

I developed a binding customization file in jaxb 2.0 in JDK 1.6.0 and it worked fine. Now I'm using jaxb 2.1.3 in JDK 1.6.0_13 and it gives me errors: Error xxx shows up in more than one properties which is what the binding file is suppose to be handling by renaming them. What happened between 2.0 and 2.1.3 that I need be aware of and...

JAXB List of Choice

I have following schema <complexType name="BookShelf"> <sequence> <element name="newBook" type="string" minOccurs="0" maxOccurs="unbounded"/> <element name="oldBook" type="string" minOccurs="0" maxOccurs="unbounded"/> </sequence> </complexType> XJC generates BookShelf class with two lists, one for newBook and one for...

Prefixing JAXB generated classes

I have this Maven "task" to generate Java classes from an XSD file using JAXB. <!-- XML to Java classes --> <plugin> <groupId>com.sun.tools.xjc.maven2</groupId> <artifactId>maven-jaxb-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>generate</goal> </g...

Generating a JAXB class that implements an interface

I'm currently using JAXB to generate java classes in order to unmarshall XML. Now I would like to create a new schema very similar to the first and have the classes that are generated implement the same interface. Say for example, I have two schema files which define XML with similar tags: adult.xsd <?xml version="1.0" encoding="UTF-8...

Java JAXB XJC code generation form XSD schema problem

Hello I have my own domain model and corresponding XSD schema for it. It consists of data types and messages that are exchanged in my application. I use XJC tool from Java JRE 1.5 for generation of Java classes for the given XSD schema. The generated classes do not contain neither the serialization/deserialization method nor the validat...

JAXB XJC code generation - ObjectFactory class is incomplete

Hello I generate Java classes from my XSD schema file using XJC command line tool. The ObjectFactory class generates incomplete content. It generates creation methods without JAXBElement<Type> createType decoration. What may be the reason of this? Regards Dominik ...

Can JAXB generate a generic class?

Can I get JAXB 2.0 XJC compiler to generate a generic class for me? Something as simple as:- public class Shape<T> { T myShape; // getter / setter } I see references for this in the spec but am not sure I'm reading it right. I always get Object references. ...

How to generate a Java class which implements Serializable interface from xsd using JAXB?

I would like to introduce caching into an existing Spring project which uses JAXB to expose WebServices. Caching will be done on the level of end points. In order to do that classes generated from XSD using JAXB need to implement Serializable interface and override Object's toString() method How to instruct the xjc tool using XSD to gen...

How to generate @XmlRootElement Classes for Base Types in XSD?

I am having some issues with generating Java Classes with appropriate JAXB annotations from an XSD using XJC. I have a relatively simple XSD file defining my XML schema. The complex types within the XSD take advantage of inheritance using the tags. The problem I having is that I need all complex types to generate Java Classes with the ...

jaxb unmarshal abusable by crafted xml when using default sax parser?

So in my current project I use the JAXB RI with the default Java parser from Sun's JRE (which I believe is Xerces) to unmarshal arbitrary XML. First I use XJC to compile an XSD of the following form: <?xml version="1.0" encoding="utf-8" ?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://...

How to make generated classes contain Javadoc from XML Schema documentation

I'm currently working with an XML Schema that has <xsd:annotation>/<xsd:documentation> on most types and elements. When I generate Java Beans from this XML Schema, then the Javadoc of those Beans only contains some generic generated information about the allowed content of the type/element. I'd like to see the content of the <xsd:docume...

Generating custom annotations using XJC

I want my classes generated from XSD schema by XJC to be annotated with custom annotations (actually specifying class name). For example, from the following XSD schema <xs:complexType name="Unit"> <xs:attribute name="Id" type="xs:string" use="required"/> </xs:complexType> XJC generates: @XmlType(name = "Unit") public class Unit ...

How to write an external binding file for xjc?

The documentation of JAXB xjc says: -b Specify one or more external binding files to process. (Each binding file must have it's own "-b" switch.) The syntax of the external binding files is extremely flexible. You may have a single binding file that contains customizations for multiple schemas or you can break the customizatio...

using jaxb with ant (xjc target): how to process multiple xsd shemas

Hi All, I'm using jaxb to generate java object class from xml schemas within an Ant script like so: <!-- JAXB compiler task definition --> <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="master-classpath"/> <!-- Generates the source code from the ff.xsd schema using jaxb --> <target name="option-generate" descr...

JAXB XJC code generation - "schemaLocation" missing in xml generated by Marshaller

Hello I Use XJC tool to generate Java classes for my XSD schema. When I use JAXB Marshaller to marshall classes into XML payloads, I'm missing "schemaLocation" parameter in the output XML, but I declare this parameter in xsd file. How to enforce "schemaLocation" parameter in the output XML? Below is the beggining of my xsd schema file ...

How generate XMLElementWrapper annotation with xjc and customized binding

Hello, I'm using JAXB and xjc to compile my XML Schema into Java classes. I do not want to manually edit this generated classes. I have xml schema like that: <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="items"> <xs:complexType> <xs:sequence> <xs:element ref="item" /...

Resolve naming conflict in included XSDs for JAXB compilation

I am currently trying to compile with JAXB (IBM build 2.1.3) a pair of schema files into the same package. Each will compile on it's own, but when trying to compile them together i get a element naming conflict due to includes. My question is; is there a way to specify with an external binding a resolution to the naming collision. Exa...

XML Schema to Java Classes with XJC

I am using xjc to generate Java classes from the XML schema and the following is an excerpt of the XSD. <xs:element name="NameInfo"> <xs:complexType> <xs:sequence> <xs:choice> <xs:element ref="UnstructuredName"/> <!-- This line --> <xs:sequence> <xs:element ref="StructuredName"/> <xs:eleme...