schemagen command for JAXB applications
Use the schema generator tool, schemagen, to generate an XML schema using Java™ Architecture for XML Binding (JAXB).
Use JAXB APIs and tools to establish mappings between an XML schema and Java classes. XML schemas describe the data elements and relationships in an XML document. After a data mapping or binding exists, you can convert XML documents to and from Java objects. You can now access data stored in an XML document without the need to understand the data structure.
You can generate a schema file from Java classes using the schemagen schema generator tool to create the XML schema. After the mapping between XML schema and Java classes exists, XML instance documents can be converted to and from Java objects through the use of the JAXB binding runtime API. The resulting Java classes contain all the necessary information that the JAXB run time requires to parse the XML for marshaling and unmarshaling. You can use the JAXB classes within Java API for XML Web Services (JAX-WS) applications or in your non-JAX-WS Java applications for processing XML data.
支援的配置: z/OS® 平台不支援 wsimport、wsgen、schemagen 和 xjc 指令行工具。
這項功能是由隨執行於 z/OS 平台的 WebSphere® Application Server 提供的組合工具所提供。請閱讀 JAX-WS 應用程式的這些指令行工具以進一步瞭解這些工具。sptcfg
最佳作法: WebSphere Application Server 提供 Java API for XML-Based Web Services (JAX-WS) 和 Java Architecture for XML Binding (JAXB) 工具。
wsimport、wsgen、schemagen 和 xjc 指令行工具位於 WebSphere Application Server 傳統版的 app_server_root\bin\ 目錄中。
xjc 和 schemagen 指令位於 Liberty 設定檔的 app_server_root\jaxb\bin\ 目錄中。
在某些情況下,WebSphere Application Server 和 JDK 提供的工具所產生的構件,支援相同層次的規格。一般而言,JDK 工具所產生的構件可以在其他標準執行時期環境之間轉移。
不過,最好的作法是利用這個產品所提供的工具來實現在 WebSphere Application Server 環境內的緊密整合,以及使用可能只在 WebSphere Application Server 環境內受到支援的特性。
如果要利用 JAX-WS 和 JAXB 2.2 版工具,請使用在 app_server_root\bin\ 目錄內之應用程式伺服器所提供的工具。bprac
避免困難: When running the schemagen tool to process JavaBeans, the schema generator will not automatically
process the @XmlSchema annotations from existing package-info.class
files to derive targetNamespaces. To assure that the schemagen tool processes namespace values correctly, use one of the following
methods:- Explicitly specify the package-info.java source file in the schemagen invocation; for example:
schemagen sample.Address sample\package-info.java - Use the @XmlType annotation namespace attribute within your JavaBeans
to specify a namespace; for example:
@XmlType(namespace="http://myNameSpace") public class Address {...}
In addition to using the schemagen tool from the command line, you can invoke this JAXB tool from within the Ant build environments. Use the com.sun.tools.jxc.SchemaGenTask Ant task from within the Ant build environment to invoke the schemagen schema generator tool. To function properly, this Ant task requires that you invoke Ant using the ws_ant script.
Syntax
The command-line syntax is:
![[Windows]](../images/windows.gif)
app_server_root\bin\schemagen.bat [options] <java_files>
![[AIX]](../images/aixlogo.gif)
![[HP-UX]](../images/hpux.gif)
![[Linux]](../images/linux.gif)
![[Solaris]](../images/solaris.gif)
app_server_root/bin/schemagen.sh [options] <java_files>
![[IBM i]](../images/iseries.gif)
app_server_root/bin/schemagen [options] <java_files>
Parameters
The following parameters are optional for the schemagen command:
- -classpath <path>
- Specifies the location of the Java source or class files.
- -cp <path>
- Specifies the location of the Java source or class files.
- -d <path>
- Specifies where to place the processor and the generated Java class files.
- -episode<file_name>
- Specifies to generate an episode file for separate compilation.
- -encoding <encoding>
- Specifies to use encoding when invoking the -apt or -javac tool. This property is applicable for JAXB 2.2 and later.
- -help
- Displays the help menu.
- -version
- Prints the version information. If you specify this option, only the version information is output and typical command processing does not occur.
參照主題