-
Notifications
You must be signed in to change notification settings - Fork 99
JAXB2 Wildcard Plugin
Wildcard plugin allows you to specify wildcard mode for the wildcard property.
Consider the following schema fragment:
<xs:complexType name="issueJIIB10Type" mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="xs:anyType"/>
</xs:complexContent>
</xs:complexType>
By default, XJC will generate the following "catch-all" property:
@XmlAnyElement(lax = true)
protected List<Object> content;
public List<Object> getContent() {
if (content == null) {
content = new ArrayList<Object>();
}
return this.content;
}
This property corresponds to the SKIP wildcard mode (strings or DOM elements only). There's also STRICT (JAXB elements only) and LAX modes (if given element is known in current JAXB context the JAXB element, otherwise DOM element). Wildcard plugin allows you to specify the desired wildcard mode - possibly overriding schema-driven defaults.
For instance, if you want this property to be generated in the LAX style, add the following customization:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wildcard="http://jaxb2-commons.dev.java.net/basic/wildcard"
jaxb:version="2.1"
jaxb:extensionBindingPrefixes="wildcard">
...
<xs:complexType name="issueJIIB10Type" mixed="true">
<xs:annotation>
<xs:appinfo>
<wildcard:lax/>
</xs:appinfo>
</xs:annotation>
<xs:complexContent mixed="true">
<xs:extension base="xs:anyType"/>
</xs:complexContent>
</xs:complexType>
...
</xs:schema>
This will change the content property:
@XmlAnyElement(lax = true)
protected List<Object> content;
Accordingly, other customization elements you can use are wildcard:strict and wildcard:skip.
You can also apply this customization globally to all schemas:
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wildcard="http://jaxb2-commons.dev.java.net/basic/wildcard"
jaxb:extensionBindingPrefixes="wildcard"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="schema.xsd" node="/xsd:schema">
<wildcard:lax/>
</jaxb:bindings>
</jaxb:bindings>
- Home
- Migration guide
-
JAXB Maven Plugin
- Quick Start
-
User Guide
- Basic Usage
- Specifying What To Compile
- Referencing Resources in Maven Artifacts
- Using Catalogs
- Using Episodes
- Modular Schema Compilation
- Controlling the Output
- Using JAXB Plugins
- Using a Specific JAXB Version
- Configuring Extension, Validation and XML Security
- IDE Integration
- Miscellaneous
- Configuring Proxies
- Maven Documentation
- Configuration Cheat Sheet
- Common Pitfalls and Problems
-
JAXB2 Basics Plugins
- Using JAXB2 Basics Plugins
- JSR-305 Support
-
JAXB2 Basics Plugins List
- SimpleEquals Plugin
- SimpleHashCode Plugin
- Equals Plugin
- HashCode Plugin
- ToString Plugin
- Copyable Plugin
- Mergeable Plugin
- Inheritance Plugin
- AutoInheritance Plugin
- Wildcard Plugin
- Setters Plugin
- Simplify Plugin
- EnumValue Plugin
- JAXBIndex Plugin
- FixJAXB1058 Plugin
- Commons Lang Plugin
- Default Value Plugin
- Fluent API Plugin
- Namespace Prefix Plugin
- Value Constructor Plugin
- Boolean Getter Plugin
- CamelCase Plugin
- XML ElementWrapper Plugin
- Parent Pointer Plugin
- Property Listener Injector Plugin
- Annox
- JAXB Annotate Plugin
-
HyperJAXB3
- Build System Support
- Customization Guide
- Databases
- Development guide
- Extension guide
- FAQ
- IDE Support
- Java Persistence
- JAXB
- JDK Support
- Project Templates
-
Reference
- Adding vendor-specific annotations
- Features
- Integrating Hyperjaxb3 in builds
- Introduction
- Making schema-derived classes ready for JPA
- Adding required properties
- Applying workarounds for JAXB vs. JPA conflicts
- Enforcing top-level classes
- Generating equals and hashCode methods
- Generating ORM metadata
- Generating persistence unit descriptor
- JPA 2 Support
- Making classes serializable
- Testing generated mappings
- Reference - single page
- Related Projects
- Sample projects
- Solutions
- Target Scenarios
- Test Projects
- Tutorials
- Best Practices
- FAQ
- Sample Projects
- Support
- License
- Distribution