Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327151

Summary: Schema gen doesn't handle multiple namespaces/packages/schemas
Product: [WebTools] Dali JPA Tools Reporter: Paul Fullbright <paul.fullbright>
Component: JAXBAssignee: Tran Le <tranle1>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jolene.moffitt, neil.hauge
Version: 3.0   
Target Milestone: 3.0 M3   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
example project none

Description Paul Fullbright CLA 2010-10-06 14:09:35 EDT
JAXB schema generation generates a schema per namespace/package, but Dali does not handle this well.  The user picks *one* schema file name and the generation mechanism (Main.JptSchemaOutputResolver to be specific) uses that file name for every namespace, which will result in a schema with errors.

We should either:

a) Limit the user to one package so that only one schema is generated (although it's unclear if that will always work, especially when that package statically references JAXB classes in other packages)

or:

b) Provide a more complete schema output resolver.  This may either require *less* user interaction (i.e. they can choose a folder, but not file names) or *more* user interaction (i.e. they have to choose a schema name/location for each namespace).
Comment 1 Neil Hauge CLA 2010-10-14 15:35:37 EDT
I'm not seeing the same thing when I try to reproduce this.  When I generate from multiple packages I get 1 schema with types defined for all of the classes in all of the specified packages.  No namespace is defined.  I had the same experience using MOXy and the JAXB RI schema generation.
Comment 2 Neil Hauge CLA 2010-10-14 15:41:22 EDT
I assume the difference is in the classes.  I don't have a namespace defined, or any JAXB annotations to begin with in this case, so I assume side-steps the problem you are encountering.  So my observations would probably only apply to that corner case.
Comment 3 Paul Fullbright CLA 2010-10-14 15:53:01 EDT
Yes, I discovered this while trying to determine what the @XmlSchema.location() value was for.  I have two packages with namespaces defined on the package annotations.

When there are no package annotations, the default namespace is "", and so all packages go into one namespace.  You'd see similar things if you actually set all packages to have the same namespace.

So the issue is really multiple namespaces, not multiple packages, per se.
Comment 4 Paul Fullbright CLA 2010-10-14 16:18:41 EDT
Created attachment 180910 [details]
example project

Here's a project with two packages, two namespaces, and should generate two schemas.
Comment 5 Tran Le CLA 2010-11-01 10:39:41 EDT
Completed in M3
The final implementation have the schema generation create files with the namespace as file name.
In the case where there is no namespace specified, the schema file name will be the default file name given by the user. If multiple schemas are generated, the file name sequence number will be incremented.
Comment 6 Jolene Moffitt CLA 2010-12-21 13:36:21 EST
Verified in Build I-3.3.0-20101209114749

Verified multiple schemas are created using namespace, if not provided schemas are created with default or file name given by user. See the link to view test steps for verification. 
http://wiki.eclipse.org/Dali_3.0_M3