Announcement Announcement Module
Collapse
No announcement yet.
xjc and multiple schemas Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • xjc and multiple schemas

    I have 3 schemas:
    S1, S2, S3 in 3 different namespaces.

    S2 imports S1 and S3 imports S1 too.

    when I use xjc -d S2 it creates two package for S2 and S1 and both package has objectFactory.

    Now the question is if I run xjc -d S3 Will S1 be regenerated or what will happen in this case?

    and How can we create one objectfactory for all the schemas? can we change the name of the class objectfactory since multiple packages has objectfactory?


    Any body has idea to manage this process of creating java classes from schemas?

    Please help.

  • #2
    Ok super quick replay because i dont have my project bewlo my eyes.
    Full answer tomorrow.

    I have almost the same configuration & i have multiple objectFactory & no problem of communs xsd imports.

    Im using a maven plugin generating those classe in a the target directory and NEVER commit them, this is a best pratice and u will be sure that your class are always up to date.

    Comment


    • #3
      Any body has idea to manage this process of creating java classes from schemas?

      Yes - here is the code needed for your case in your pom.xml:

      Code:
      <plugin>
      	    <groupId>org.jvnet.jaxb2.maven2</groupId>
      	    <artifactId>maven-jaxb2-plugin</artifactId>
      		<version>0.7.5</version>
      	      <executions>
      			<execution>
      			  <id>generate-S1-and-S3</id>
      			  <goals>
      		        <goal>generate</goal>
      			  </goals>
      			  <configuration>		     
                    <schemaDirectory>src/main/resources/schemas</schemaDirectory>		     
      		      <schemaIncludes>
      			    <include>S2.xsd</include>
      			    <include>S3.xsd</include>
      		      </schemaIncludes>
                    </configuration>
      		    </execution>
      		  </executions>
      	    </plugin>
      As you can read, you dont need to precise S1.His code will be generated in a specif package according to his nameSpace by default.
      And the plugin seems to be clever enough to not regenerate everything after each mvn compile.

      But you can force the regeneration with
      Code:
      forceRegenerate>true</forceRegenerate>
      as well


      How can we create one objectfactory for all the schemas? can we change the name of the class objectfactory since multiple packages has objectfactory?

      I dont know why you want so much a single ObjectFactory but you might find and answer with customizing JAXB Binding

      Comment

      Working...
      X