Rectangle 27 4

You create an instance of Test and ScreensType but never set any of their properties before marshalling them to XML. Below is the corrected code.

public void generateXml() throws JAXBException, IOException {
    Test test = new Test();
    ScreensType screens = new ScreensType();
    test.getOption1OrOption2OrOption3().add(screens);
    ScreenType screen = new ScreenType();
    screen.setName1("a");
    screen.setName2("b");
    screen.setName3("c");
    screens.getScreen().add(screen);

    File f = new File("new.xml");
    JAXBContext context= JAXBContext.newInstance("com.q1labs.qa.xmlgenerator.model.generatedxmlclasses");
    Marshaller jaxbMarshaller = context.createMarshaller();
    jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

    jaxbMarshaller.marshal(test, f);
    jaxbMarshaller.marshal(test, System.out);
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Test xmlns="http://ibm.org/seleniumframework">
    <Option3>
        <Screen name1="a" name2="b" name3="c"/>
    </Option3>
</Test>

That worked! Thanks very much! I'm new to JAXB so you've been a lot of help.

@Colin747 - I happy I could help. BTW, I maintain a Java XML and JSON Binding blog that you may find useful: blog.bdoughan.com

java - Creating an XML file from XSD from JAXB - Stack Overflow

java xml xsd jaxb
Rectangle 27 92

in JAXB that is part of JDK1.6

marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

This does not give the expected result. This removes all the XML declaration line. What I want is just removing the standalone attribute in the XML declaration.

If you wonder why this isn't working for you, just like I did, then the answer is that the effect depends on which marshal api you are using. For marshal(Object,Outputstream) and marshal(Object,Writer) this works as suggested here. For marshal(Object, Node) it has no effect. For the remaining marshal api implications have a look here under the Supported Properties section.

xsd - JAXB - Remove 'standalone="yes"' from generated XML - Stack Over...

xml xsd jaxb xml-binding
Rectangle 27 92

in JAXB that is part of JDK1.6

marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

This does not give the expected result. This removes all the XML declaration line. What I want is just removing the standalone attribute in the XML declaration.

If you wonder why this isn't working for you, just like I did, then the answer is that the effect depends on which marshal api you are using. For marshal(Object,Outputstream) and marshal(Object,Writer) this works as suggested here. For marshal(Object, Node) it has no effect. For the remaining marshal api implications have a look here under the Supported Properties section.

xsd - JAXB - Remove 'standalone="yes"' from generated XML - Stack Over...

xml xsd jaxb xml-binding
Rectangle 27 1

XML is designed to facilitate change and flexibility in document structures. Unfortunately, JAXB isn't. The very act of compiling knowledge of document structure into your Java source code makes change to the document structure a lot more difficult.

If structural change is part of your agenda, I think you should seriously consider not using JAXB: technologies like XQuery and XSLT are much better suited to this scenario.

java - Support XSD versioning with JAXB - Stack Overflow

java xml xsd jaxb
Rectangle 27 1

After trying for couple of days, eventually i was able to create the xml from xsd properly using the code given below. Hope this helps :

String filename = "<filepath/filename>";

          final Document doc = loadXsdDocument(filename);

       //Find the docs root element and use it to find the targetNamespace
            final Element rootElem = doc.getDocumentElement();
            String targetNamespace = null;
            if (rootElem != null && rootElem.getNodeName().equals("xs:schema")) 
                       {
                targetNamespace = rootElem.getAttribute("targetNamespace");
            }


                        //Parse the file into an XSModel object
            XSModel xsModel = new XSParser().parse(filename);

                        //Define defaults for the XML generation
            XSInstance instance = new XSInstance();
            instance.minimumElementsGenerated = 1;
            instance.maximumElementsGenerated = 1;
            instance.generateDefaultAttributes = true;
            instance.generateOptionalAttributes = true;
            instance.maximumRecursionDepth = 0;
            instance.generateAllChoices = true;
            instance.showContentModel = true;
            instance.generateOptionalElements = true;

                        //Build the sample xml doc
                        //Replace first param to XMLDoc with a file input stream to write to file
            QName rootElement = new QName(targetNamespace, "<xsd file name>");
            XMLDocument sampleXml = new XMLDocument(new StreamResult(System.out), true, 4, null);
            instance.generate(xsModel, rootElement, sampleXml);
        } catch (TransformerConfigurationException e) 
                {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static Document loadXsdDocument(String inputName) {
        final String filename = inputName;

        final DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();
        factory.setValidating(false);
        factory.setIgnoringElementContentWhitespace(true);
        factory.setIgnoringComments(true);
        Document doc = null;

        try {
            final DocumentBuilder builder = factory.newDocumentBuilder();
            final File inputFile = new File(filename);
            doc = builder.parse(inputFile);
        } catch (final Exception e) {
            e.printStackTrace();
            // throw new ContentLoadException(msg);
        }

        return doc;
    }

java - Creating an XML file from XSD from JAXB - Stack Overflow

java xml xsd jaxb
Rectangle 27 17

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="todo">
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:element name="doLaundry" type="doLaundry" />
                <xs:element name="washCar" type="washCar" />
                <xs:element name="tidyBedroom" type="tidyBedroom" />
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType abstract="true" name="Task">
        <xs:attribute name="cost" type="xs:int" use="required" />
    </xs:complexType>

    <xs:complexType name="doLaundry">
        <xs:complexContent>
            <xs:extension base="Task">
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="washCar">
        <xs:complexContent>
            <xs:extension base="Task">
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="tidyBedroom">
        <xs:complexContent>
            <xs:extension base="Task">
                <xs:attribute name="experiencePoints" type="xs:int" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

</xs:schema>

combined with a binding file:

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings>
      <jxb:bindings schemaLocation="todo.xsd" node="/xs:schema/xs:complexType[@name='todo']/xs:sequence/xs:choice">
            <jxb:property name="Tasks"/>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

Will give abstract and inherited classes as I described in the question. The binding file will change Jaxb's default method name from getDoLaundryOrWashCarOrTidyBedroom() to getTasks().

Polymorphism in XSD schema and JAXB classes - Stack Overflow

xsd jaxb
Rectangle 27 41

For Eclipse STS (3.5 at least) you don't need to install anything. Right click on schema.xsd -> Generate -> JAXB Classes. You'll have to specify the package & location in the next step and that's all, your classes should be generated. I guess all the above mentioned solutions work, but this seems by far the easiest (for STS users).

[UPDATE] Eclipse STS version 3.6 (based on Kepler) comes with the same functionality.

In Eclipse Kepler, the tools seems not to be there anymore

Note that you need to install the "dali" JAXB webtools to get that menu option. See eclipse.org/webtools/dali

You can add jaxb-impl jar rather than installing "dali" web tools

java - How to generate JAXB classes from XSD? - Stack Overflow

java java-ee jaxb
Rectangle 27 38

For Eclipse STS (3.5 at least) you don't need to install anything. Right click on schema.xsd -> Generate -> JAXB Classes. You'll have to specify the package & location in the next step and that's all, your classes should be generated. I guess all the above mentioned solutions work, but this seems by far the easiest (for STS users).

[UPDATE] Eclipse STS version 3.6 (based on Kepler) comes with the same functionality.

In Eclipse Kepler, the tools seems not to be there anymore

Note that you need to install the "dali" JAXB webtools to get that menu option. See eclipse.org/webtools/dali

You can add jaxb-impl jar rather than installing "dali" web tools

java - How to generate JAXB classes from XSD? - Stack Overflow

java java-ee jaxb
Rectangle 27 6

xsd:choice corresponds to the @XmlElements annotation. You could apply this annotation directly to your desired object model.

I think I didn't make my question clear enough intially. I am starting with an XSD schema and want to generate the Java classes from that with JAXB. I'd like to know if it is possible to structure the XSD in such a way as to give the desired Java object model - not the other way round.

You could define an inheritance relationship between the types in your XML schema. Check out this post for an example: bdoughan.blogspot.com/2010/11/

Polymorphism in XSD schema and JAXB classes - Stack Overflow

xsd jaxb
Rectangle 27 8

You can use the -episode extension in the JAXB XJC to handle this use case:

xjc -d out -episode common.episode common.xsd

The episode file produced from the first step is really a JAXB external bindings file that contains links between schema types and existing classes. This prevents XJC from regenerating these classes.

xjc -d out objectA.xsd -extension -b common.episode

For a Detailed Example

I tried using that but i still result in the CommonType being generated both times

I had to add the necessary XML schema imports <xs:import namespace="http://test.com/magic/common" schemaLocation="common.xsd"/> but once I did I was able to use the command line XJC as described in my answer to only generate the classes from common.xsd once.

that's correct the command line works as expected but for some reason the maven plugin is not working even when i specify <episodeFile> <extenstion> <bindingInclude> configurations

jaxb - Create a common xsd generated class to be used by other package...

xsd jaxb xjc maven-jaxb2-plugin
Rectangle 27 9

I guess it's also the same problem that I had: you added javax.persistence as a Maven dependency, but not as a dependency to your JAXB plugin:

Add something like this (if you're using Hibernate):

</project>
    ...
    <build>
      <plugins>
        <plugin>
          <groupId>org.jvnet.jaxb2.maven2</groupId>
          <artifactId>maven-jaxb2-plugin</artifactId>
          <version>${maven-jaxb2-plugin.version}</version>
          <executions>
             ...
          </executions>
          <configuration>
             ...
          </configuration>
          <dependencies>
            <!-- Hibernate Persistence Annotations -->
            <dependency>
              <groupId>org.hibernate.javax.persistence</groupId>
              <artifactId>hibernate-jpa-2.0-api</artifactId>
              <version>${hibernate-jpa-2.0-api.version}</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </build>
    ...
</project>

I had a similar issue and was able to solve it with that. In the following example please note that I'm putting the annotations into the XSD and not into the XJB file but the Maven configuration should be similar.

<?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"
  elementFormDefault="qualified" targetNamespace="http://www.gl-group.com/ewelding/schemas"
  xmlns:ew="http://www.companyname.com/project/schemas"
  xmlns:xmime="http://www.w3.org/2005/05/xmlmime" jaxb:extensionBindingPrefixes="annox"
  xmlns:annox="http://annox.dev.java.net"
  xmlns:ja="http://annox.dev.java.net/javax.xml.bind.annotation"
  xmlns:jpa="http://annox.dev.java.net/javax.persistence"
  xmlns:solrj="http://annox.dev.java.net/org.apache.solr.client.solrj.beans"
  xmlns:jackson="http://annox.dev.java.net/com.fasterxml.jackson.annotation">

...
<xs:element name="Certificate">
  <xs:annotation>
    <xs:appinfo>
      <annox:annotate>
        <ja:XmlAccessorType value="NONE"/>
        <jpa:Entity name="Certificate"/>
        <solrj:Field value="testByOrderOf"/>
        <jackson:JsonFormat shape="STRING" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT"/>
      </annox:annotate>
    </xs:appinfo>
  </xs:annotation>
  ...
  <xs:element ref="ew:dateOfBirth">
    <xs:annotation>
      <xs:appinfo>
        <annox:annotate target="field">
          <solrj:Field value="dateOfBirth"/>
          <jackson:JsonFormat shape="STRING" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT"/>
        </annox:annotate>
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  ...
</xs:element>

And here are the relevant sections from my pom.xml:

...
<properties>
  ...
  <maven-jaxb2-plugin.version>0.8.3</maven-jaxb2-plugin.version>
  <jaxb2-basics.version>0.6.4</jaxb2-basics.version>
  <jaxb2-value-constructor.version>3.0</jaxb2-value-constructor.version>
  <solr-solrj.version>4.3.0</solr-solrj.version>
  <jackson.version>2.2.2</jackson.version>
  <hibernate-jpa-2.0-api.version>1.0.1.Final</hibernate-jpa-2.0-api.version>
  ...
</properties>
...
<build>
  <plugins>
    ...
    <!-- Generate Java sources from XSD schema files -->
    <plugin>
      <groupId>org.jvnet.jaxb2.maven2</groupId>
      <artifactId>maven-jaxb2-plugin</artifactId>
      <version>${maven-jaxb2-plugin.version}</version>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <extension>true</extension>
        <args>
          <arg>-Xannotate</arg>
          <arg>-Xvalue-constructor</arg>
          <arg>-Xinheritance</arg>
          <arg>-enableIntrospection</arg>
        </args>
        <!-- Include our schema -->
        <schemaDirectory>src/main/resources</schemaDirectory>
        <schemaIncludes>
          <include>certificate.xsd</include>
        </schemaIncludes>
        <bindingIncludes>
          <bindings>certificate.xjb</bindings>
        </bindingIncludes>
        <generateDirectory>src/main/java</generateDirectory>
        <generatePackage>com.company.project.generated</generatePackage>
        <plugins>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>${jaxb2-basics.version}</version>
          </plugin>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics-annotate</artifactId>
            <version>${jaxb2-basics.version}</version>
          </plugin>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-value-constructor</artifactId>
            <version>${jaxb2-value-constructor.version}</version>
          </plugin>
        </plugins>
      </configuration>
      <dependencies>
        <!-- SolrJ - only needed for the @Field annotation -->
        <dependency>
          <groupId>org.apache.solr</groupId>
          <artifactId>solr-solrj</artifactId>
          <version>${solr-solrj.version}</version>
        </dependency>

        <!-- Jackson2 Annotations -->
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
          <version>${jackson.version}</version>
        </dependency>

        <!-- Hibernate Persistence Annotations -->
        <dependency>
          <groupId>org.hibernate.javax.persistence</groupId>
          <artifactId>hibernate-jpa-2.0-api</artifactId>
          <version>${hibernate-jpa-2.0-api.version}</version>
        </dependency>
      </dependencies>
    </plugin>
    ...
  </plugins>
</build>

I had the same exception, this fixed it. Just be aware that my example puts everything into the XSD and not into the XJB... but the dependency-thing mentioned above should help you as well.

xsd - Not able to generate annotation through maven jaxb plugin - Stac...

xsd jpa-2.0 maven-3 maven-jaxb2-plugin jaxb2-maven-plugin
Rectangle 27 4

You want the xjc tool. It sits alongside schemagen in the JDK, and generates JAXB-annotated java from an XML Schema. See official JavaSE docs here.

xsd - Tool for creating a JAXB java class out of xml schema (reverse s...

java xsd jaxb
Rectangle 27 4

You are facing a so-called "chameleon schema" which is considered to be a bad practice. Unfortunately, there is no good solution due to the nature of JAXB. JAXB annotation bind bean properties to XML elements and attributes in specific namespaces (determined in the schema compile time). So once your schema is compiled, there is no official good way to change namespaces of elements and attributes your properties are bound to.

However, this is exactly what you want to achieve with "chameleon" schemas. Classes derived from "common.xsd" should somehow magically map to namespace A if used in A classes and to namespace B if used in B classes. I can imagine this magic, but never seen in in real life.

Since you essentially want A/common and B/common to be the "same thing", one of the ways to resolve it is to generate A and B (both with common) in two executions and to make common classes implement a certain "common" interface. Then your software could process A/common and B/common in the same faschion regardless of the fact that these are actually classes from the different packages.

From the comment I see that you don't have a chameleon schema, but just a normal importing. It is easy then, just compile common, A and B separately. See the Separate schema compilation for maven-jaxb2-plugin.

The common.xsd is in its own namespace and its imported in the same namespace in AService.xsd and BService.xsd. There is no need to change namespaces after generation..

Please see the update. It is easier then.

Your approach will work too, i added an answer myself describing how i came up with the solution. Thanks for the reply.

java - JAXB: Generating classes for two XSDs which share a common XSD ...

java xsd jaxb
Rectangle 27 4

You get a list of JAXBElement<TTrack>. So you can check e.getName() to find out if it is an audio or a video track.

You can use my Simplify plugin to get audio and video tracks in separate properties. This is not exactly the model you have in your schema, but pretty close and much easier to use.

<xs:complexType name="typeWithReferencesProperty">
    <xs:choice maxOccurs="unbounded">
        <xs:element name="a" type="someType">
            <xs:annotation>
                <xs:appinfo>
                    <simplify:as-element-property/>
                </xs:appinfo>
            </xs:annotation>
        </xs:element>
        <xs:element name="b" type="someType"/>
    </xs:choice>
</xs:complexType>
@XmlElement(name = "a")
protected List<SomeType> a;
@XmlElement(name = "b")
protected List<SomeType> b;

The reason you get this model is the maxOccurs on your choice.

Also consider using xs: or xsd: prefixes for your XML Schema.

maven - Generate java classes from xsd with jaxb from a choice - Stack...

java maven jaxb xsd
Rectangle 27 1

You can create a json directly from the classes created with jaxb.

Any json library can create the json from a pojo instance.

Here are the steps:

  • Create the classes from the xsd using the tool xjc
  • Create an instance of the classes
  • Pass the instance to the pojo library and create a String from it

Creating a random object can be done with a code similar to the following. Note that this code creates only primitive types and objects with primitive types or references to other objects. For arrays, list, maps you need to enhance it.

public class RandomObjectFiller {

    private Random random = new Random();

    public <T> T createAndFill(Class<T> clazz) throws Exception {
        T instance = clazz.newInstance();
        for(Field field: clazz.getDeclaredFields()) {
            field.setAccessible(true);
            Object value = getRandomValueForField(field);
            field.set(instance, value);
        }
        return instance;
    }

    private Object getRandomValueForField(Field field) throws Exception {
        Class<?> type = field.getType();


        if(type.equals(Integer.TYPE) || type.equals(Integer.class)) {
            return random.nextInt();
        } else if(type.equals(Long.TYPE) || type.equals(Long.class)) {
            return random.nextLong();
        } else if(type.equals(Double.TYPE) || type.equals(Double.class)) {
            return random.nextDouble();
        } else if(type.equals(Float.TYPE) || type.equals(Float.class)) {
            return random.nextFloat();
        } else if(type.equals(String.class)) {
            return UUID.randomUUID().toString();
        } 
        return createAndFill(type);
    }
}

The previous example using this class is the following code:

ObjectMapper mapper = new ObjectMapper();

RandomObjectFiller randomObjectFiller = new RandomObjectFiller();

// PojoClass is the class created with xjc from your xsd
PojoClass pojoInstance = randomObjectFiller.createAndFill(PojoClass.class);

String jsonString = mapper.writeValueAsString(pojoInstance);
System.out.println(jsonString);  // Print the pojoInstance as json string

Unfortunately, that requires me to populate the POJO, instead of just using default/random values... (I want to optimize for laziness... ;-)

@Christian so your problem is not transforming objects to json, but how to populate an object with random values?

@Christian check the updated answer. I added a second part to show how to create objects with random properties.

java - What's a quick and simple way to generate a sample JSON documen...

java json xml xsd jaxb
Rectangle 27 7

<jaxb:bindings node="//xs:element[@name='ArchiveTransferRequest']
    /xs:complexType/xs:sequence/xs:element[@name='Contains']
    /xs:complexType/xs:sequence/xs:element[@name='Contains']">

I took your XSD and fixed it to make it a legal document. Then I took your XPath expressions, they selected the xs:element correctly.

There's only one more thing you need to do to make this working: select the xs:complexType, not the xs:element, because that is what JAXB uses to create the classes, not the elements.

The following should work:

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               version="2.1">
    <jaxb:bindings schemaLocation="seda_actes.xsd">
        <jaxb:bindings node="//xs:element[@name='ArchiveTransferRequest']
            /xs:complexType/xs:sequence/xs:element[@name='Contains']
            /xs:complexType/xs:sequence/xs:element[@name='Contains']
            /xs:complexType">
            <jaxb:class name="SecondContains"/>
        </jaxb:bindings>
         <jaxb:bindings node="//xs:element[@name='ArchiveTransferRequest']
             /xs:complexType/xs:sequence/xs:element[@name='Contains']
             /xs:complexType/xs:sequence/xs:element[@name='Contains']
             /xs:complexType/xs:sequence/xs:element[@name='Contains']
             /xs:complexType">
            <jaxb:class name="ThirdContains"/>
        </jaxb:bindings>
    </jaxb:bindings>

</jaxb:bindings>

java - Nested elements in XSD cause Illegal class inheritance loop exc...

java xpath xsd jaxb jaxb2
Rectangle 27 2

JAXB does not have a default enum value name for enum values corresponding to "". Your JAXB implementation can generate a Java enum corresponding to this XML schema type if you use an external bindings file to provide a name.

<jxb:bindings
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">
    <jxb:bindings schemaLocation="your-schema.xsd">
        <jxb:bindings node="//xs:simpleType[@name='matchAnalysisType']/xs:restriction/xs:enumeration[@value='']">
            <jxb:typesafeEnumMember name="BLANK"/>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

The binding file is specified in the XJC call using the -b parameter:

xjc -b binding.xml your-schema.xsd

pleas seemmy response above. FYI, not sure how you can add a large 'comment' to an answer.

xsd - Xml Schema / JaxB -- How to enable empty enumerations, string, i...

jaxb xsd
Rectangle 27 2

I resolved the problem with the simplify approach in a .xjb file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"     xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:annox="http://annox.dev.java.net" xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd" version="2.1" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" extensionBindingPrefixes="simplify">

  <jaxb:bindings schemaLocation="http://xxx/Core.xsd">
    <jaxb:bindings node="/xs:schema/xs:complexType[@name='TStreamRecorder']/xs:sequence/xs:choice/xs:element[1]">
      <simplify:as-element-property />
    </jaxb:bindings>
  </jaxb:bindings>

</jaxb:bindings>
<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
      <execution>
        <id>process-xsd</id>
        <goals>
          <goal>generate</goal>
        </goals>

        <phase>generate-sources</phase>
        <configuration>
          <args>
            <arg>-Xsimplify</arg>
            <arg>-Xannotate</arg>                
          </args>

          <schemas>
            <schema>
              <url>http://xxxConfiguration.xsd</url>
            </schema>
          </schemas>

          <bindingIncludes>
            <include>schema/configBinding.xjb</include>
            <include>schema/coreBinding.xjb</include>
          </bindingIncludes>


        </configuration>
      </execution>
    </executions>
  </plugin>

maven - Generate java classes from xsd with jaxb from a choice - Stack...

java maven jaxb xsd
Rectangle 27 3

A single xsd file can only define a single namespace. you need a separate xsd which defines the second namespace, which you would then import into the original xsd (and reference the attribute accordingly).

java - How to specify an attribute namespace in XSD so that JAXB inter...

java xml namespaces jaxb xsd