-
Notifications
You must be signed in to change notification settings - Fork 37
Configuration in Binding Files
Binding files allow customizing schema compilation.
Binding files are typically named bindings.xjb
(the .xjb
extension is used by convention). They can be specified using the -b
command-line or Ant options or via bindings
or bindingIncludes
configuration elements of the Maven plugin.
The typical bindings file is structured as follows:
<jaxb:bindings
version="1.0"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jsonix="http://jsonix.highsource.org/customizations"
jaxb:extensionBindingPrefixes="jsonix">
<jaxb:bindings schemaLocation="schema.xsd"
node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.acme.foo.myschema"/>
</jaxb:schemaBindings>
<!-- Further customization elements -->
</jaxb:bindings>
</jaxb:bindings>
The <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema" ... />
applies customizations to schema defined in the schema.xsd
file. This element may contain further configuration or customization elements.
To configure the Jsonix Schema Compiler in binding files:
- Use the
jaxb:schemaBinding
element to specify the package name for your schema (via the `jaxb:schemaBinding/jaxb:package/@name attribute). - Use the specified package name to associate mappings with this schema (
jsonix:mapping/@package
attribute).
Assume we have a schema defined in the schema.xsd
file. In the example below we use binding files to associate the package name com.acme.foo.myschema
with this schema. Later on we use this package name (com.acme.foo.myschema
) to configure a mapping named MySchema
for our schema. This mapping will be included into the module named MyModule
. As there's no output configured, default will apply and we'll get the MyModule.js
with standard naming.
<jaxb:bindings
version="1.0"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jsonix="http://jsonix.highsource.org/customizations"
jaxb:extensionBindingPrefixes="jsonix">
<jaxb:bindings schemaLocation="schema.xsd"
node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.acme.foo.myschema"/>
</jaxb:schemaBindings>
<jsonix:module name="MyModule">
<jsonix:mapping package="com.acme.foo.myschema" name="MySchema"/>
</jsonix:module>
</jaxb:bindings>
</jaxb:bindings>
A binding file may contain the following configuration elements:
-
module
- module configuration. -
output
- default output configuration. -
mapping
- mapping configuration (will be automatically wrapped into a module).
- Usage
- Basic Concepts
- Generation
- Configuration
- Advanced Topics
- Sample Projects
- Troubleshooting
- Development