Java Reference
In-Depth Information
Table2-4.Binding scopes
Scope
Description
Global (uses <glob-
alBindings> )
Applies to all schema elements in the current schema, as well as all schemas impor-
ted or included by the current schema, recursively.
Schema (uses <s-
chemaBindings> )
Applies to all schema elements in the target namespace of the current schema.
Definition
Applies to the element in which the binding is specified, as well as all other schema
elements that reference this type definition.
Component
Applies only to the element in which the binding is specified.
These scopes can override one another, with the most specific scope always overriding any
more general scopes that would have covered it.
Now let's look at the two ways to use these bindings.
Using Inline Annotations
The first of two ways to customize your generated code is to use inline annotations. XML
Schema makes available the <appinfo> child element of <annotation> specifically for
the purpose of allowing applications to perform customization for their environment. See
Example 2-21 .
Example2-21.Customizing JAXB with a Schemalet file
<xs:schema elementFormDefault="qualified" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0"
targetNamespace="urn:schemalet:calendar">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings mapSimpleTypeDef="false"
choiceContentProperty="true">
<jaxb:javaType name="java.util.Date" xmlType="xs:date"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.printDate"/>
<jaxb:javaType name="java.util.Date" xmlType="xs:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.printDate"/>
Search WWH ::




Custom Search