0

I am trying to generate jaxb classes from from the xsd mentioned below.

Page.xsd

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://www.m.com/a"  xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:import schemaLocation="NewXMLSchema5.xsd"/> 

  <xs:element name="collection" type="tns:collection"/>

  <xs:element name="links" type="tns:links"/>


  <xs:complexType name="collection">
    <xs:complexContent>
      <xs:extension base="basePage">
        <xs:sequence>
          <xs:element ref="tns:links" minOccurs="0"/>
          <xs:element name="element" type="xs:anyType" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="pageData" type="PageData" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="type" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="links">
    <xs:all/>
  </xs:complexType>
</xs:schema>

In the above xsd, extension basePage definition is there under NewXMLSchema5.xsd. Because of NewXMLSchema5.xsd, when I am generating jaxb classes for the Page.xsd , it is generating jaxb classes for page.xsd and NewXMLSchema5.xsd.

My requirement is I need to generate jaxb classes only for Page.xsd .it should ignore the NewXMLSchema5.xsd which is imported in page.xsd.But the basePage definition should be available in NewXMLSchema5.xsd.

Can anybody advice how to ignore NewXMLSchema5.xsd in page.xsd and at the same basePage definition should be available in page.xsd.

raj
  • 107
  • 2
  • 11

1 Answers1

0

You can use episode compilation to use the existing (already generated) types from another schema.

Firstly, you will have to execute the NewXMLSchema5.xsd with

xjc -episode newschema.episode NewXMLSchema5.xsd

Then use the episode to generate the Page.xsd

xjc Page.xsd -extension -b newschema.episode

This way, the the baseType shall not be generated but used from previous generation.

refer this link for similar answer.

Community
  • 1
  • 1
ulab
  • 1,079
  • 3
  • 15
  • 45