Reputation: 83
What is the inline option for something like this
xjc -d . -b bindings.xjb Derived.xsd
where my bindings.xsd will have
<bindings scd="~tns:NameType">
<class ref="com.bcbsmt.eie.pojo.commontypes.NameType"/>
</bindings>
All i want to do is to prevent duplication of NameType everywhere.The requirement though is strictly internal binding.
I tried in Derived.xsd something like
<xs:element name="Name">
<xs:annotation>
<xs:appinfo>
<jaxb:class implClass="com.bcbsmt.eie.pojo.commontypes.NameType"></jaxb:class>
</xs:appinfo>
</xs:annotation>
</xs:element>
But this didnt work out.Any ideas
Upvotes: 2
Views: 5199
Reputation: 149007
I'm not sure I fully understand your question, but below is an example of how the jaxb:class
schema annotation can be used to point to an existing class.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.1">
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element ref="bar"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="bar">
<xs:complexType>
<xs:annotation>
<xs:appinfo>
<jaxb:class ref="example.BarImpl"></jaxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
If you want to reuse all the types generated from an XML schema, then you may find episode files useful:
Upvotes: 2