Java - Jaxb - Xjc - JAXB (schema|binding) compiler)

Java Conceptuel Diagram

Java - Jaxb - Xjc - JAXB (schema|binding) compiler)

Usage

Usage: xjc [-options ...] <schema file/URL/dir/jar> ... [-b <bindinfo>] ...
If dir is specified, all schema files in it will be compiled.
If jar is specified, /META-INF/sun-jaxb.episode binding file will be compiled.
Options:
  -nv                :  do not perform strict validation of the input schema(s)
  -extension         :  allow vendor extensions - do not strictly follow the
                        Compatibility Rules and App E.2 from the JAXB Spec
  -b <file/dir>      :  specify external bindings files (each <file> must have its own -b)
                        If a directory is given, **/*.xjb is searched
  -d <dir>           :  generated files will go into this directory
  -p <pkg>           :  specifies the target package
  -httpproxy <proxy> :  set HTTP/HTTPS proxy. Format is [user[:password]@]proxyHost:proxyPort
  -httpproxyfile <f> :  Works like -httpproxy but takes the argument in a file to protect password
  -classpath <arg>   :  specify where to find user class files
  -catalog <file>    :  specify catalog files to resolve external entity references
                        support TR9401, XCatalog, and OASIS XML Catalog format.
  -readOnly          :  generated files will be in read-only mode
  -npa               :  suppress generation of package level annotations (**/package-info.java)
  -no-header         :  suppress generation of a file header with timestamp
  -target 2.0        :  behave like XJC 2.0 and generate code that doesnt use any 2.1 features.
  -xmlschema         :  treat input as W3C XML Schema (default)
  -relaxng           :  treat input as RELAX NG (experimental,unsupported)
  -relaxng-compact   :  treat input as RELAX NG compact syntax (experimental,unsupported)
  -dtd               :  treat input as XML DTD (experimental,unsupported)
  -wsdl              :  treat input as WSDL and compile schemas inside it (experimental,unsupported)
  -verbose           :  be extra verbose
  -quiet             :  suppress compiler output
  -help              :  display this help message
  -version           :  display version information


Extensions:
  -Xlocator          :  enable source location support for generated code
  -Xsync-methods     :  generate accessor methods with the 'synchronized' keyword
  -mark-generated    :  mark the generated code as @javax.annotation.Generated
  -episode <FILE>    :  generate the episode file for separate compilation

Example

xjc -p myPackage mySchema.xsd

where the options:

  • -p define the package destination name

Binding

Xjb

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
	version="2.1"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
	xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
	jaxb:extensionBindingPrefixes="hj orm">

	<jaxb:globalBindings generateIsSetMethod="true">
                    <jaxb:javaType name="java.lang.String" xmlType="xs:token"
                        parseMethod="formatter.StringAdapter.parseString"
                        printMethod="formatter.StringAdapter.printString"/>
                    <jaxb:javaType name="java.lang.Long" xmlType="xs:unsignedInt" />
                    <jaxb:javaType name="java.lang.Integer" xmlType="xs:integer" />
                    <jaxb:javaType name="java.lang.Boolean" xmlType="xs:boolean" />
        </jaxb:globalBindings>
	
	<jaxb:bindings schemaLocation="xudml1.xsd" node="/xs:schema">
		<jaxb:schemaBindings>
			<jaxb:package name="com.gerardnico.biserver"/>
		</jaxb:schemaBindings>
	</jaxb:bindings>
	
	<!--<jaxb:bindings schemaLocation="xudml1.xsd" node="/xs:schema">
		.../second xsd
	</jaxb:bindings>-->
	
</jaxb:bindings>

Default Package definition for the creation of the adapter

<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2001/XMLSchema"
	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
	<annotation>
		<appinfo>
			<jaxb:schemaBindings>
				<jaxb:package name="org.acme.foo" />
			</jaxb:schemaBindings>
		</appinfo>
	</annotation>
</schema>





Discover More
Java Conceptuel Diagram
Java - Java API for XML Binding (JAXB) - (Un)Marshaller

API JAXB is a serialization library (Java binding tool) between XML and Object. It uses annotations to bind XML documents to a java object model. Located under the javax.xml.bind package. It generates...
Card Puncher Data Processing
XML - (XML Schema Definition|XSD) (Schema With Capital S)

The in XML. XML Schema definition language (Xsd) is a language that define an XML schema (usually written in the W3C XML Schema Language). It provides functionality...



Share this page:
Follow us:
Task Runner