Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Creating an XML Project (ELUG)

Revision as of 09:43, 9 March 2009 by Rick.sapir.oracle.com (Talk | contribs) (Creating an XML Project from an XML Schema)

This section describes the various components that you must configure in order to create an XML project.

For information on how to create more than one type of EclipseLink projects, see Creating a Project.


Introduction to XML Project Creation

You can create a project using the Workbench or Java code.

We recommend using the Workbench to create projects and generate deployment XML or Java source versions of the project for use at run time. For more information on how to create a project using Workbench, see How to Create a Project Using the Workbench. For information on how to create a project using Java, see How to Create a Project Using Java.

You can use EclipseLink to create an XML project, if you have an XML schema (XSD) document, but no object model yet (see Creating an XML Project from an XML Schema). If you have both XSD and object model classes, you can create an XML project using the procedure described in How to Create a Project Using the Workbench

For more information, see Introduction to XML Projects.


Creating an XML Project from an XML Schema

EclipseLink 1.x supports JAXB 2.0 and uses the JAXB 2.0 schema compiler. You can use this JAXB compiler to generate POJO (Plain Old Java Objects) annotated with JAXB 2.0 mapping metadata. You can define and edit this JAXB metadata by embedding these annotations in your source code -- not the Eclipse Workbench.

To use the Eclipse Workbench to define XPath based mappings:

  1. Create an XML project.
  2. Import your schema and classes into the project.
  3. Define the mappings between your classes and schema.


The EclipseLink JAXB compiler generates JAXB-specific files and EclipseLink-specific files.

Optionally, open the generated workbench project), customize the generated mappings and descriptors, and reexport the EclipseLink project XML.


Note: Before you compile your generated classes, be sure to configure your IDE classpath to include <ECLIPSELINK_HOME>\jlib\moxy\javax.xml.bind_2.0.0.jar. For example, see Using an Integrated Development Environment.


How to Create an XML Project from an XML Schema Using the Command Line

To create a new, mapped Workbench project from an XML schema using JAXB from the command line, use the jaxb-compiler.cmd or jaxb-compiler.sh file (located in the <ECLIPSELINK_HOME>/bin directory) as follows:

  1. Using a text editor, edit the jaxb-compiler.cmd or jaxb-compiler.sh file to set proxy settings (if required).
    If you are using a schema that imports another schema by URL and you are operating behind a proxy, then you must uncomment the lines shown in the Proxy Settings in jaxb-compiler.cmd or Proxy Settings in jaxb-compiler.sh examples and edit them to set your proxy host (name or IP address) and port:
    Proxy Settings in jaxb-compiler.cmd

    @REM set JVM_ARGS=%JVM_ARGS% -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort=


    Proxy Settings in jaxb-compiler.sh

    1. JVM_ARGS="${JVM_ARGS} -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort="
  2. Execute the jaxb-compiler.cmd or jaxb-compiler.sh file (located in the <ECLIPSELINK_HOME>/bin directory).
    The EclipseLink JAXB compiler generates JAXB-specific files (see Working with JAXB-Specific Generated Files) and EclipseLink-specific files (see Working with EclipseLink-Specific Generated Files).
    The Generating an Object Model from a Schema with jaxb-compiler.cmd example illustrates how to generate an object model from a schema using the EclipseLink JAXB compiler. The EclipseLink JAXB Binding Compiler Arguments table lists the compiler arguments.
    Generating an Object Model from a Schema with jaxb-compiler.cmd

    jaxb-compiler.cmd -sourceDir ./app/src -generateWorkbench -workbenchDir ./app/mw -schema purchaseOrder.xsd
    -targetPkg examples.ox.model.if -implClassPkg examples.ox.model.impl


    EclipseLink JAXB Binding Compiler Arguments

    Argument Description Optional?

    -help

    Prints this usage information.

    Yes

    -version

    Prints the release version of the EclipseLink JAXB compiler.

    Yes

    -sourceDir

    The path to the directory into which generated interfaces, implementation classes, and deployment files are written.

    Default: directory named source in the specified output directory.

    Yes

    -generateWorkbench

    Generate a Workbench project and necessary project files. If omitted, only runtime information is generated.

    Yes

    -workbenchDir

    The path to the directory into which the Workbench project files are written. This argument requires the -generateWorkbench argument.

    Default: directory named mw in the specified output directory.

    Yes

    -schema

    The fully qualified path to your XSD file.

    No

    -targetPkg

    The name of the package to which both generated interfaces and classes belong. This defines your context path. To specify a different package for implementation classes, set the -implClassPkg argument.

    Default: a package name of jaxbderived.<schema name> where <schema name> is the name of the schema specified by the -schema argument.

    Yes

    -implClassPkg

    The name of the package to which generated implementation classes belong. If this option is set, interfaces belong to the package specified by the -targetPkg argument. This defines your context path.

    Yes

    -interface

    Generate only interfaces. This argument is optional.

    Default: generate both interfaces and implementation classes.

    Yes

    -verbose

    The interfaces and classes generated. This argument is optional.

    Default: not verbose.

    Yes

    -customize

    The fully qualified path and file name of a standard JAXB customization file that you can use to override default JAXB compiler behavior.

    Yes


  3. Optionally, open the generated Workbench project in Workbench, customize the generated mappings and descriptors, and reexport the EclipseLink project XML.

    Note: Before you compile your generated classes, be sure to configure your IDE classpath to include <ECLIPSELINK_HOME>\jlib\moxy\javax.xml.bind_2.0.0.jar. For example, see Using an Integrated Development Environment.



Copyright Statement

Back to the top