仕様バージョン: 2.1
リファレンス実装 (RI) バージョン: 2.1.3
バインディングコンパイラを起動するには、使用するプラットフォームに応じた bin
ディレクトリ内の xjc
シェルスクリプトを使用します。また、バインディングコンパイラを実行するための Ant タスクも用意されています。XJC Ant タスクの使用の手順を参照してください。
% xjc -help
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
"-b"
スイッチを指定する必要があります。) 外部バインディングファイルの構文は非常に柔軟です。複数のスキーマのカスタマイズが含まれる 1 つのバインディングファイルを使用したり、それらのカスタマイズを複数のバインディングファイルに分割したりできます。次に例を示します。
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings123.xjb
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings1.xjb -b bindings2.xjb -b bindings3.xjb
また、コマンド行にスキーマファイルとバインディングファイルを指定する順番は任意です。 -host
および -port
は、下位互換性のためにリファレンス実装でもサポートされていますが、推奨されなくなりました。このオプションで指定されたパスワードは、top
コマンドを使用するユーザーなど、ほかのユーザーが表示できる引数であることに注意してください。セキュリティーを高めるには、次の -httpproxyfile
を使用してください。 <jxb:javaType>
および <xjc:superClass>
カスタマイズが使用するクライアントアプリケーションのクラスファイルの検索場所を指定します。catalog-resolver
のサンプルアプリケーションを調べてください。synchronized
キーワードが含められます。@javax.annotation.Generated
を付けます。通常は、関連するすべてのスキーマを、同じバインディングコンパイラスイッチを指定して 1 つの単位としてコンパイルするのがもっとも安全です。
xjc を実行するときは、次に示す制限に注意してください。これらの制限のほとんどは、xjc を何度か呼び出して複数のスキーマをコンパイルする場合にのみ適用されます。
-p
コマンド行オプションがもっとも優先されます。jaxb:package
> のカスタマイズtargetNamespace
が宣言されている場合は、仕様に定義されている targetNamespace
-> Java パッケージ名のアルゴリズムを適用します。targetNamespace
が宣言されていない場合は、"generated" という名前のハードコードされたパッケージを使用します。jaxb:schemaBindings
> を持つことは不正です。このため、1 つのターゲット名前空間内の 2 つのスキーマを、異なる Java パッケージにコンパイルすることはできません。