Manjula
Manjula

Reputation: 5091

Can we generate JAXB classes for a set of xsd in multiple packages?

I have an xsd which has several child XSD s embedded (using "xsd:include".) in it (but each xsd belongs to the same namespace). I was asked to generate jaxb classes in separate sub packages (one sub package per each child XSD) instead of one package.

According to what I have read so far, we can add jaxb:schemaBindings to these separate xsds and generate the classes in separate packages, if only those xsds belong to different namespaces.

But in my case, what I want to do is to create classes in several sub packages for a set of xsds belong to the same namespace. Could you please help me to do this using JAXB?


Edit: I have added little more description about my problem to clarify it little bit more.

All of my XSDs has following header. Therefore same namespace.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:srm="http://www.mycompany.com/srm/"
    targetNamespace="http://www.mycompany.com/srm/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0" elementFormDefault="qualified"
    attributeFormDefault="unqualified" version="1.0">

Let's say my schema file names are A.xsd, B.xsd, and C.xsd.

I want to generate JAXB classes like I have mentioned below.

Upvotes: 5

Views: 6585

Answers (1)

bdoughan
bdoughan

Reputation: 148977

You could generate JAXB classes from each of the "included" schemas separately into separate packages and leverage the episode mechanism available in the XJC tool.

Examples (from answers given on Stack Overflow)

Upvotes: 3

Related Questions