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

Difference between revisions of "Creating an XML Project (ELUG)"

m
m
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Image:Elug draft icon.png]] '''For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/ '''
 +
 +
----
 +
 +
 +
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
[[Special:Whatlinkshere/Creating an XML Project (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Creating an XML Project (ELUG)|Related Topics]]</div>
Line 19: Line 25:
  
 
==Creating an XML Project from an XML Schema==
 
==Creating an XML Project from an XML Schema==
If you have an existing data model (XML schema document), but you do not have a corresponding object model (Java classes for domain objects), use this procedure to create your EclipseLink project and automatically generate the corresponding object model.
+
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:
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
+
#[[Creating%20a%20Project%20(ELUG)#How to Create a Project Using the Workbench|Create an XML project]].
| align="left" |
+
#[[Using_Workbench_(ELUG)#How_to_Import_an_XML_Schema|Import your schema]] and [[Using_Workbench_(ELUG)#How_to_Import_and_Update_Classes|classes]] into the project.
'''Note:''' If you have both XSD and object model classes, you can create an XML project using the procedure described in [[Creating%20a%20Project%20(ELUG)#How to Create a Project Using the Workbench|How to Create a Project Using the Workbench]].
+
#[[Configuring_an_XML_Mapping_%28ELUG%29|Define the mappings]] between your classes and schema.
|}
+
 
+
 
+
Using the EclipseLink JAXB compiler simplifies JAXB application development with EclipseLink by automatically generating both the required JAXB files and the EclipseLink files from your XML schema (XSD) document. Once generated, you can open the Workbench project to fine-tune XML mappings without having to recompile your JAXB object model.
+
 
+
You can use the EclipseLink JAXB compiler from [[#How to Create an XML Project from an XML Schema Using Workbench|the Workbench]] or from the [[#How to Create an XML Project from an XML Schema Using the Command Line|command line ]].
+
 
+
 
+
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
+
| align="left" |
+
'''Note:''' Before you compile your generated classes, be sure to configure your IDE classpath to include <tt><</tt>''<tt>ECLIPSELINK_HOME</tt>''<tt>>\lib\xml.jar</tt>. For example, see [[Using%20an%20Integrated%20Development%20Environment%20(ELUG)|Using an Integrated Development Environment]].
+
|}
+
 
+
 
+
For more information, see the following:
+
* [[Introduction%20to%20XML%20Projects%20(ELUG)#EclipseLink Support for Java Architecture for XML Binding (JAXB)|EclipseLink Support for Java Architecture for XML Binding (JAXB)]]
+
* [[Introduction%20to%20XML%20Projects%20(ELUG)#Using EclipseLink JAXB Compiler Generated Files at Run Time|Using EclipseLink JAXB Compiler Generated Files at Run Time]]
+
 
+
 
+
===How to Create an XML Project from an XML Schema Using Workbench===
+
To create a new, mapped Workbench project from an XML schema using JAXB, use this procedure:
+
# From Workbench, select '''File > New > Project > From XML Schema (JAXB)'''.<br><span id="Figure 53-1"></span>''''' Create Workbench Project using JAXB Dialog Box'''''<br>[[Image:creatjaxb.gif|Create Workbench Project using JAXB Dialog Box]]
+
# Complete each field on the Create Workbench Project using JAXB dialog box, and then click '''OK'''.
+
 
+
Use the following information to enter data in each field of this dialog box:
+
 
+
 
+
{| class="HRuleInformalWide" dir="ltr" title="This table identifies each field on the Create Workbench Project using JAXB dialog." summary="This table identifies each field on the Create Workbench Project using JAXB dialog." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
+
|- align="left" valign="top"
+
! id="r1c1-t4" align="left" valign="bottom" | '''Field'''
+
! id="r1c2-t4" align="left" valign="bottom" | '''Description'''
+
|- align="left" valign="top"
+
| id="r2c1-t4" headers="r1c1-t4" align="left" | '''From'''
+
| headers="r2c1-t4 r1c2-t4" align="left" | Use these fields to specify your existing JAXB information.
+
|- align="left" valign="top"
+
| id="r3c1-t4" headers="r1c1-t4" align="left" | <blockquote>'''Schema File'''</blockquote>
+
| headers="r3c1-t4 r1c2-t4" align="left" | Click '''Browse''' and select the fully qualified path to your XSD file.
+
|- align="left" valign="top"
+
| id="r4c1-t4" headers="r1c1-t4" align="left" | <blockquote>'''JAXB Customization File'''</blockquote>
+
| headers="r4c1-t4 r1c2-t4" align="left" | This in an optional setting. It can be used if you have a standard JAXB configuration file that you wish to use to override the default JAXB compiler behavior. The JAXB customization file contains binding declarations for customizing the default binding between an XSD component and its Java representation.
+
|- align="left" valign="top"
+
| id="r5c1-t4" headers="r1c1-t4" align="left" | '''To'''
+
| headers="r5c1-t4 r1c2-t4" align="left" | Use these fields to specify the location and options of the Workbench project.
+
|- align="left" valign="top"
+
| id="r6c1-t4" headers="r1c1-t4" align="left" |<blockquote>''' Output Directory'''</blockquote>
+
| headers="r6c1-t4 r1c2-t4" align="left" | Click '''Browse''' and select the path to the directory into which generated files are written. All paths used in the project are relative to this directory.
+
|- align="left" valign="top"
+
| id="r7c1-t4" headers="r1c1-t4" align="left" | <blockquote>'''Output Source Directory'''</blockquote>
+
| headers="r7c1-t4 r1c2-t4" align="left" | Click '''Browse''' and select the path to the directory (relative to the '''Output Directory''') into which generated interfaces, implementation classes, and deployment files are written. Default: directory named <tt>source</tt> in the specified output directory.
+
|- align="left" valign="top"
+
| id="r8c1-t4" headers="r1c1-t4" align="left" | <blockquote>'''Output Workbench Project Directory'''</blockquote>
+
| headers="r8c1-t4 r1c2-t4" align="left" | Click Browse and select the path to the directory (relative to the '''Output Directory''') into which the Workbench project files are written. Default: directory named <tt>mw</tt> in the specified output directory.
+
|- align="left" valign="top"
+
| id="r9c1-t4" headers="r1c1-t4" align="left" | <blockquote>''' Package Name for Generated Interfaces'''</blockquote>
+
| headers="r9c1-t4 r1c2-t4" align="left" | The optional name of the package to which generated interfaces belong. This defines your context path. If it is not specified, a package name of <tt>jaxbderived.<schema name></tt> is used where <tt><schema name></tt> is the name of the schema specified by the '''Schema File''' field.
+
|- align="left" valign="top"
+
| id="r10c1-t4" headers="r1c1-t4" align="left" | <blockquote>'''Package Name for Generated Implementation Classes'''</blockquote>
+
| headers="r10c1-t4 r1c2-t4" align="left" | The optional name of the package to which generated implementation classes belong. This defines your context path. If it is not specified, a package name of <tt>jaxbderived.<schema name></tt> is used where <tt><schema name></tt> is the name of the schema specified by the '''Schema File''' field.
+
|}
+
  
  
Line 93: Line 40:
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
| align="left" |
 
| align="left" |
'''Note:''' Before you compile your generated classes, be sure to configure your IDE classpath to include <tt><</tt>''<tt>ECLIPSELINK_HOME</tt>''<tt>>\lib\xml.jar</tt>. For example, see [[Using%20an%20Integrated%20Development%20Environment%20(ELUG)|Using an Integrated Development Environment]].
+
'''Note:''' Before you compile your generated classes, be sure to configure your IDE classpath to include <tt><</tt>''<tt>ECLIPSELINK_HOME</tt>''<tt>>\jlib\moxy\javax.xml.bind_2.0.0.jar</tt>. For example, see [[Using%20an%20Integrated%20Development%20Environment%20(ELUG)|Using an Integrated Development Environment]].
 
|}
 
|}
 +
  
  
 
===How to Create an XML Project from an XML Schema Using the Command Line===
 
===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 <tt>tljaxb.cmd</tt> or <tt>tljaxb.sh</tt> file (located in the ''<tt><ECLIPSELINK_HOME></tt>''<tt>/bin</tt> directory) as follows:
+
To create a new, mapped Workbench project from an XML schema using JAXB from the command line, use the <tt>jaxb-compiler.cmd</tt> or <tt>jaxb-compiler.sh</tt> file (located in the ''<tt><ECLIPSELINK_HOME></tt>''<tt>/bin</tt> directory) as follows:
 
<ol>
 
<ol>
<li> Using a text editor, edit the <tt>tljaxb.cmd</tt> or <tt>tljaxb.sh</tt> file to set proxy settings (if required).<br>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 [[#Example 53-1|Proxy Settings in tljaxb.cmd]] or [[#Example 53-2|Proxy Settings in tljaxb.sh]] examples and edit them to set your proxy host (name or IP address) and port:
+
<li> Using a text editor, edit the <tt>jaxb-compiler.cmd</tt> or <tt>jaxb-compiler.sh</tt> file to set proxy settings (if required).<br>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 [[#Example 53-1|Proxy Settings in jaxb-compiler.cmd]] or [[#Example 53-2|Proxy Settings in jaxb-compiler.sh]] examples and edit them to set your proxy host (name or IP address) and port:
 +
 
 
<br><span id="Example 53-1"></span>
 
<br><span id="Example 53-1"></span>
''''' Proxy Settings in tljaxb.cmd'''''  
+
''''' Proxy Settings in jaxb-compiler.cmd'''''  
 
<div class="pre">
 
<div class="pre">
@REM set JVM_ARGS=%JVM_ARGS% -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort=
+
@REM set JVM_ARGS=%JVM_ARGS% -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort=
 
</div>
 
</div>
 +
 
<br><span id="Example 53-2"></span>
 
<br><span id="Example 53-2"></span>
''''' Proxy Settings in tljaxb.sh'''''  
+
''''' Proxy Settings in jaxb-compiler.sh'''''  
 
<div class="pre">
 
<div class="pre">
# JVM_ARGS="${JVM_ARGS} -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort="
+
JVM_ARGS="${JVM_ARGS} -DproxySet=true -Dhttp.proxyHost= -Dhttp.proxyPort="
 
</div>
 
</div>
 
</li>
 
</li>
<li> Execute the <tt>tljaxb.cmd</tt> or <tt>tljaxb.sh</tt> file (located in the ''<tt><ECLIPSELINK_HOME></tt>''<tt>/bin</tt> directory).<br>The EclipseLink JAXB compiler generates JAXB-specific files (see [[Introduction%20to%20XML%20Projects%20(ELUG)|Working with JAXB-Specific Generated Files]]) and EclipseLink-specific files (see [[Introduction%20to%20XML%20Projects%20(ELUG)|Working with EclipseLink-Specific Generated Files]]).<br>The [[#Example 53-3|Generating an Object Model from a Schema with tljaxb.cmd]] example illustrates how to generate an object model from a schema using the EclipseLink JAXB compiler. The [[#Table 53-1|EclipseLink JAXB Binding Compiler Arguments]] table lists the compiler arguments.
+
 
 +
<li> Execute the <tt>jaxb-compiler.cmd</tt> or <tt>jaxb-compiler.sh</tt> file (located in the ''<tt><ECLIPSELINK_HOME></tt>''<tt>/bin</tt> directory).<br>The EclipseLink JAXB compiler generates JAXB-specific files (see [[Introduction%20to%20XML%20Projects%20(ELUG)|Working with JAXB-Specific Generated Files]]) and EclipseLink-specific files (see [[Introduction%20to%20XML%20Projects%20(ELUG)|Working with EclipseLink-Specific Generated Files]]).<br>The [[#Example 53-3|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 [[#Table 53-1|EclipseLink JAXB Binding Compiler Arguments]] table lists the compiler arguments.
 +
 
 
<br><span id="Example 53-3"></span>
 
<br><span id="Example 53-3"></span>
''''' Generating an Object Model from a Schema with tljaxb.cmd'''''  
+
''''' Generating an Object Model from a Schema with jaxb-compiler.cmd'''''  
 
<div class="pre">
 
<div class="pre">
tljaxb.cmd -sourceDir ./app/src -generateWorkbench -workbenchDir ./app/mw  -schema purchaseOrder.xsd<br> -targetPkg examples.ox.model.if -implClassPkg examples.ox.model.impl
+
jaxb-compiler.cmd [-options...] schemafile [-b bindingfile]
 
</div>
 
</div>
<br>
+
 
 +
 
 
<span id="Table 53-1"></span>
 
<span id="Table 53-1"></span>
 
''''' EclipseLink JAXB Binding Compiler Arguments'''''
 
''''' EclipseLink JAXB Binding Compiler Arguments'''''
 
+
{| class="HRuleFormalMax" dir="ltr" title="EclipseLink JAXB Binding Compiler Arguments" summary="This table describes the mandatory and optional arguments used with the EclipseLink JAXB binding compiler." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
{| class="HRuleFormalMax" dir="ltr" title="EclipseLink JAXB Binding Compiler Arguments" summary="This table describes the mandatory and optional arguments used with the EclispeLink JAXB binding compiler." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
+
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
! id="r1c1-t6" align="left" valign="bottom" | '''Argument'''
 
! id="r1c1-t6" align="left" valign="bottom" | '''Argument'''
Line 131: Line 83:
 
<tt>-help</tt>
 
<tt>-help</tt>
 
| headers="r2c1-t6 r1c2-t6" align="left" |
 
| headers="r2c1-t6 r1c2-t6" align="left" |
Prints this usage information.
+
Prints the help and usage information.
 
| headers="r2c1-t6 r1c3-t6" align="left" |
 
| headers="r2c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
Line 141: Line 93:
 
| headers="r3c1-t6 r1c3-t6" align="left" |
 
| headers="r3c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r4c1-t6" headers="r1c1-t6" align="left" |
+
| id="r11c1-t6" headers="r1c1-t6" align="left" |
<tt>-sourceDir</tt>
+
<tt>-verbose</tt>
| headers="r4c1-t6 r1c2-t6" align="left" |
+
| headers="r11c1-t6 r1c2-t6" align="left" |
The path to the directory into which generated interfaces, implementation classes, and deployment files are written.
+
The interfaces and classes generated. This argument is optional.
  
Default: directory named <tt>source</tt> in the specified output directory.
+
Default: not verbose.
| headers="r4c1-t6 r1c3-t6" align="left" |
+
| headers="r11c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r5c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-generateWorkbench</tt>
+
<tt>-customize</tt>
| headers="r5c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
Generate a Workbench project and necessary project files. If omitted, only runtime information is generated.
+
The fully qualified path and file name of a standard JAXB customization file that you can use to override default JAXB compiler behavior.
| headers="r5c1-t6 r1c3-t6" align="left" |
+
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r6c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-workbenchDir</tt>
+
<tt>-nv</tt>
| headers="r6c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
The path to the directory into which the Workbench project files are written. This argument requires the <tt>-generateWorkbench</tt> argument.
+
Do not preform strict validation of the input schemas.
 
+
| headers="r12c1-t6 r1c3-t6" align="left" |
Default: directory named <tt>mw</tt> in the specified output directory.
+
| headers="r6c1-t6 r1c3-t6" align="left" |
+
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r7c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-schema</tt>
+
<tt>-extension</tt>
| headers="r7c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
The fully qualified path to your XSD file.
+
Allow vendor extensions. The compiler will not strictly follow the Compatibility Rules and Appendix E.2 or the JAXB specification.  
| headers="r7c1-t6 r1c3-t6" align="left" |
+
| headers="r12c1-t6 r1c3-t6" align="left" |
No
+
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r8c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-targetPkg</tt>
+
<tt>-b</tt>
| headers="r8c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
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 <tt>-implClassPkg</tt> argument.
+
Specify external bindings files (or directories). <br>
  
Default: a package name of <tt>jaxbderived.<schema name></tt> where <tt><schema name></tt> is the name of the schema specified by the <tt>-schema</tt> argument.
+
<tt>-b file1 -b file2 -b file3</tt>
| headers="r8c1-t6 r1c3-t6" align="left" |
+
 
 +
If you include a directory, the compiler will search <tt>**/*.xjb</tt>.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r9c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-implClassPkg</tt>
+
<tt>-d</tt>
| headers="r9c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
The name of the package to which generated implementation classes belong. If this option is set, interfaces belong to the package specified by the <tt>-targetPkg</tt> argument. This defines your context path.
+
The directory for the generated files.
| headers="r9c1-t6 r1c3-t6" align="left" |
+
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r10c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-interface</tt>
+
<tt>-p</tt>
| headers="r10c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
Generate only interfaces. This argument is optional.
+
The target package.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-httpproxy</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
Set an HTTP/HTTPS proxy.
  
Default: generate both interfaces and implementation classes.
+
<tt>-httpproxy [user[:password]@]proxyHost:proxy:Port</tt>
| headers="r10c1-t6 r1c3-t6" align="left" |
+
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r11c1-t6" headers="r1c1-t6" align="left" |
+
| id="r12c1-t6" headers="r1c1-t6" align="left" |
<tt>-verbose</tt>
+
<tt>-httpproxyfile</tt>
| headers="r11c1-t6 r1c2-t6" align="left" |
+
| headers="r12c1-t6 r1c2-t6" align="left" |
The interfaces and classes generated. This argument is optional.
+
Similar to <tt>-httpproxy</tt>, except that it takes a file (to protect the password).
  
Default: not verbose.
+
<tt>-httpproxyfile file</tt>
| headers="r11c1-t6 r1c3-t6" align="left" |
+
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-classpath</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
Specify the location of your class files
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-catalog</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
Specify the catalog files to resolve external entity references. The JAXB compiler supports TR9401, XCatalog, and OASIS XML catalog formats.
 +
 +
<tt>-catalog filename</tt>
 +
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 
| id="r12c1-t6" headers="r1c1-t6" align="left" |
Line 212: Line 199:
 
| headers="r12c1-t6 r1c2-t6" align="left" |
 
| headers="r12c1-t6 r1c2-t6" align="left" |
 
The fully qualified path and file name of a standard JAXB customization file that you can use to override default JAXB compiler behavior.
 
The fully qualified path and file name of a standard JAXB customization file that you can use to override default JAXB compiler behavior.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-readonly</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The generated files will be in read-only mode.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-npa</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The package-level annotations ''''will not'''' be generated (**/package-info.java).
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-no-header</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The file header with timestamp '''will not''' be generated.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-xmlschmea</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The input schema will be treated as W3C schema (default).
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-relaxng</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The input schema will be treated as RELAX NG
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-relaxng-compact</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The input schmea will be treated as RELAX NG (compact syntax).
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-wsdl</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The input schmea will be treated as WSDL and compile shemas inside of it.
 +
| headers="r12c1-t6 r1c3-t6" align="left" |
 +
Yes
 +
|
 +
|- align="left" valign="top"
 +
| id="r12c1-t6" headers="r1c1-t6" align="left" |
 +
<tt>-dtd</tt>
 +
| headers="r12c1-t6 r1c2-t6" align="left" |
 +
The input schmea will be trated as XML DTD.
 
| headers="r12c1-t6 r1c3-t6" align="left" |
 
| headers="r12c1-t6 r1c3-t6" align="left" |
 
Yes
 
Yes
 
|}
 
|}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
<br>
 
<br>
 
</li>
 
</li>
Line 221: Line 281:
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
| align="left" |
 
| align="left" |
'''Note:''' Before you compile your generated classes, be sure to configure your IDE classpath to include <tt><</tt>''<tt>ECLIPSELINK_HOME</tt>''<tt>>\lib\xml.jar</tt>. For example, see [[Using%20an%20Integrated%20Development%20Environment%20(ELUG)|Using an Integrated Development Environment]].
+
'''Note:''' Before you compile your generated classes, be sure to configure your IDE classpath to include <tt><</tt>''<tt>ECLIPSELINK_HOME</tt>''<tt>>\jlib\moxy\javax.xml.bind_2.0.0.jar</tt>. For example, see [[Using%20an%20Integrated%20Development%20Environment%20(ELUG)|Using an Integrated Development Environment]].
 
|}
 
|}
 
</li>
 
</li>
 
</ol>
 
</ol>
 
 
  
  
Line 234: Line 292:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1.1]]
 
[[Category: Task]]
 
[[Category: Task]]
 
[[Category: XML]]
 
[[Category: XML]]

Latest revision as of 15:07, 16 July 2012

Elug draft icon.png For the latest EclipseLink documentation, please see http://www.eclipse.org/eclipselink/documentation/



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

    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 [-options...] schemafile [-b bindingfile]


    EclipseLink JAXB Binding Compiler Arguments

    Argument Description Optional?

    -help

    Prints the help and usage information.

    Yes

    -version

    Prints the release version of the EclipseLink JAXB compiler.

    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

    -nv

    Do not preform strict validation of the input schemas.

    Yes

    -extension

    Allow vendor extensions. The compiler will not strictly follow the Compatibility Rules and Appendix E.2 or the JAXB specification.

    Yes

    -b

    Specify external bindings files (or directories).

    -b file1 -b file2 -b file3

    If you include a directory, the compiler will search **/*.xjb.

    Yes

    -d

    The directory for the generated files.

    Yes

    -p

    The target package.

    Yes

    -httpproxy

    Set an HTTP/HTTPS proxy.

    -httpproxy [user[:password]@]proxyHost:proxy:Port

    Yes

    -httpproxyfile

    Similar to -httpproxy, except that it takes a file (to protect the password).

    -httpproxyfile file

    Yes

    -classpath

    Specify the location of your class files

    Yes

    -catalog

    Specify the catalog files to resolve external entity references. The JAXB compiler supports TR9401, XCatalog, and OASIS XML catalog formats.

    -catalog filename

    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

    -readonly

    The generated files will be in read-only mode.

    Yes

    -npa

    The package-level annotations 'will not' be generated (**/package-info.java).

    Yes

    -no-header

    The file header with timestamp will not be generated.

    Yes

    -xmlschmea

    The input schema will be treated as W3C schema (default).

    Yes

    -relaxng

    The input schema will be treated as RELAX NG

    Yes

    -relaxng-compact

    The input schmea will be treated as RELAX NG (compact syntax).

    Yes

    -wsdl

    The input schmea will be treated as WSDL and compile shemas inside of it.

    Yes

    -dtd

    The input schmea will be trated as XML DTD.

    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