users@jaxb.java.net

RE: jaxb 2.0 multiple schemas

From: Perry, Steve <Steve.Perry_at_fnf.com>
Date: Thu, 18 Aug 2005 13:14:03 -0500

Scott: since you said the main schema includes many different schema
files, I assume they're all in the same targetNamespace (by using
<xs:include>). If that's the case, you will not be able to customize
them to go to different packages. If you try you will get a message
like: [ERROR] Multiple <schemaBindings> are defined for the target
namespace "whatever"
 
You will need to specify different targetNamespaces for each package
group you want generated (and, of course, change the <xs:include> to
<xs:import>. Once you do this, you can either customize the package
name, or allow JAXB to derive it based on the targetNamespace.
 
HTH
 
--steve

Steve Perry

Fidelity Information Services

Email: steve.perry_at_fnf.com

Check out my blog! http://jstevenperry.javadevelopersjournal.com
<http://jstevenperry.javadevelopersjournal.com/>

 

        -----Original Message-----
        From: Scott Allan [mailto:sallan1000_at_aol.com]
        Sent: Wednesday, August 17, 2005 11:07 PM
        To: users_at_jaxb.dev.java.net
        Subject: jaxb 2.0 multiple schemas
        
        
        
        I hope this is not too confusing to follow...
         
        I have a main schema that includes many different schema files.
Currently all the classes get written to the same package using
jaxb:schemaBindings and jaxb:package in the main schema. I want to be
able to split the generated classes into different packages such as an
ejb package and second package that would be able to use the classes in
the ejb package as complex types. How can I do this?
         
        I came across this documentation (shown below) but I don't know
if it solves my problem or how I would implement it. Do I have to
rename my schemas to .rng and change <xs:schema> to <grammar>? Does
everything else stay the same? Does the xs namespace go away for these
schemas? Can I still use the plugins? Can you mix the xs:schemas and
relaxng schemas? A working example would be great.
         
        The following example shows how to divide the generated code
into two packages by using the RELAX NG <div> tag:

        <grammar xmlns="http://relaxng.org/ns/structure/1.0"
          xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
          jaxb:version="1.0">
          
          <div>
            <jaxb:schemaBindings>
              <jaxb:package name="com.acme.foo"/>
            </jaxb:schemaBindings>
            
            ... RELAX NG declarations ...
          </div>
          
          
          <div>
            <jaxb:schemaBindings>
              <jaxb:package name="com.acme.bar"/>
            </jaxb:schemaBindings>
            
            ... RELAX NG declarations ...
          </div>
          
        </grammar>
        

        If you have two schemas, foo.rng and bar.rng, one of which
includes the other, you can put them into two separate packages just by
writing a <schemaBindings> element for each schema file.


  _____

<< ella for Spam Control >> has removed 25482 Spam messages and set
aside 2 Newsletters for me
You can use it too - and it's FREE! www.ellaforspam.com