xjc

Add toString, hashCode, equals while generating JAXB classes in Java

允我心安 提交于 2019-12-18 03:34:09
问题 I'm trying to generate JAXB classes from an XSD file programmatically, using Java. I've used the following code snippet to achieve that: .... import java.io.File; import java.io.IOException; import org.xml.sax.InputSource; import com.sun.codemodel.JCodeModel; import com.sun.tools.xjc.api.S2JJAXBModel; import com.sun.tools.xjc.api.SchemaCompiler; import com.sun.tools.xjc.api.XJC; .... .... public static void generateJaxb(String schemaPath, String outputDirectory, String packageName) throws

How to disable Java Naming Conventions in xjc?

狂风中的少年 提交于 2019-12-17 19:46:01
问题 For example sOmE_PROPerty in xsd must be sOmE_PROPerty in java class not someProperty. I tried to use globalBindings enableJavaNamingConventions="false" but it doesn't work. 回答1: You will need to use underscoreBinding="asCharInWord" instead of enableJavaNamingConventions="false" : customer.xsd <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.example.org/customer" xmlns="http://www.example.org/customer" xmlns:xsd="http://www.w3.org/2001/XMLSchema"

JAXB xjc mapping to existing domain objects

流过昼夜 提交于 2019-12-17 16:10:15
问题 I have done a lot of searching and cannot find a concise example of how to map an XML schema to existing domain objects instead of creating brand new ones utilizing xjc . I have created a bindings (xjb) file but still can find no way of accomplishing this. If I have an existing domain Object that I want JAXB to use such as the following: package com.blah.domain; class CustomerOffice{ private int id; private String name; private String phone; } And I have an XML Schema like the following: <

How to deal with JAXB ComplexType with MixedContent data?

浪尽此生 提交于 2019-12-17 12:34:11
问题 I got this XML structure: <Tax> <Money currency="USD">0.00</Money> <Description xml:lang="en"> 17.5% Non-Recoverable <ShortName>vatspecial</ShortName> </Description> </Tax> Notice that Description node has MixedContent (composed with text and XML) and this is the XSD part regarding Description node : <xsd:complexType name="TaxDescriptionType"> <xsd:sequence> <xsd:element name="ShortName" type="xsd:string" /> </xsd:sequence> <xsd:attribute ref="xml:lang" /> </xsd:complexType> Everything is ok

What is the role of ClassOutline / JClass / CClass in CodeModel?

*爱你&永不变心* 提交于 2019-12-17 06:13:29
问题 My question concerns writing JAXB plugins, in particular JAXB codemodel. What is the role of ClassOutline (and it's companions) and JClass (and companions) and CClass (and companions)? When looking at the list of classes in corresponding packages it is not clear what is chicken and what is egg. My interpretation is that CClass ( CPropertyInfo , CEnumConstant , ...) are created by XJC at first draft parsing of XSD. Then some magic happens and this model is transformed into JClass ( JFieldVar ,

How to generate java class with @XmlRootElement from WSDL using xjc in command prompt

纵饮孤独 提交于 2019-12-13 17:21:53
问题 The xjc way of creating java package is xjc -wsdl myWsdl.wsdl This creates package like com Then for generation of jar jar cvf myJar.jar com/* Any way to generate the java classes with @XmlRootElement because my java class does not have it. PS: using command prompt only 回答1: To force generating @XmlRootElement , refer How to generate @XmlRootElement Classes for Base Types in XSD? please. However, I think you don't need to use @XmlRootElement . The post, No @XmlRootElement generated by JAXB

Compile several XSD's containing duplicate definitions of the same element with JAXB

帅比萌擦擦* 提交于 2019-12-13 12:03:27
问题 Question: How do i make xjc/Jaxb generate the propper javaclasses for several schemas containing duplicate elementdefinitions in the same namespace? Information: I have three .xsd schemas: A,B and C. All have the same targetnamespace. They are all 3 shemas that has been given to me, and i am not, in any way possible, allowed to change them in any way. They A has some elements that is also found in B or C (but A has a lot of self declared elements as well) Example: This is the same "code" for

Partial-unmarshalling with JAXB

你离开我真会死。 提交于 2019-12-13 11:44:15
问题 I want do partial unmarshaling of big XML. XML has following structure: <Records> <Contract> ... </Contract> <Contract> ... </Contract> ... <Contract> ... </Contract> <Contract> ... </Contract> </Records> And result class generated with XJC: - Records |- Contract If i follow these(sample from jaxb-ri), i get error: Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"http://somedomain.com", local:"Contract"). Expected elements are <{http://somedomain.com

JAXB bindings - set typesafeEnumBase to empty (convert enumerations to strings)

别来无恙 提交于 2019-12-12 21:14:33
问题 According to the link If typesafeEnumBase is set to xsd:string, it would be a global way to specify that all simple type definitions deriving directly or indirectly from xsd:string and having enumeration facets should be bound by default to a typesafe enum. If typesafeEnumBase is set to an empty string, "" , no simple type definitions would ever be bound to a typesafe enum class by default. The value of typesafeEnumBase can be any atomic simple type definition except xsd:boolean and both

XJC Plugin customizations

给你一囗甜甜゛ 提交于 2019-12-12 19:06:22
问题 I'm developing XJC plugin which uses customizations. The problem is I get [ERROR] compiler was unable to honor this myPlugin:testAnnotation customization. It is attached to a wrong place, or its inconsistent with other bindings. line 16 of file:/C:/JaxbPlugin_jar/withInternalBinding/sampleInlineAnnotation.xsd [ERROR] (the above customization is attached to the following location in the schema) line 13 of file:/C:/JaxbPlugin_jar/withInternalBinding/sampleInlineAnnotation.xsd Here is my schema: