eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
205 stars 111 forks source link

XJC Dependent on Order of XSDs Listed on Command Line #906

Open Tomas-Kraus opened 12 years ago

Tomas-Kraus commented 12 years ago

I have created a simplified example that shows that XJC is dependent on the order of the XSDs specified on the command line. In my example (attached), I have 3 XSDs in 2 namespaces:

The command below fails:

>java -jar ../../lib/jaxb-ri-20120516/lib/jaxb-xjc.jar -verbose com/example/ns/A.xsd com/example/ns/B.xsd com/example/ns2/A2.xsd

parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'ns:bType' to a(n) 'type definition' component.
  line 10 of file:/in-work/lobo/mmaxey/logs/jaxb/com/example/ns2/A2.xsd

If I switch the order of A.xsd and B.xsd on the command line (making B.xsd first), it works:

>java -jar ../../lib/jaxb-ri-20120516/lib/jaxb-xjc.jar -verbose com/example/ns/B.xsd com/example/ns/A.xsd com/example/ns2/A2.xsd
parsing a schema...
compiling a schema...
[INFO] generating code
unknown location

com/example/ns/AType.java
com/example/ns/BType.java
com/example/ns/ObjectFactory.java
com/example/ns/package-info.java
com/example/ns2/AType.java
com/example/ns2/ObjectFactory.java
com/example/ns2/package-info.java

Is this the expected behavior?

Affected Versions

[2.2.5]

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 12 years ago

@glassfishrobot Commented Reported by mmaxey

Tomas-Kraus commented 12 years ago

@glassfishrobot Commented yaroska said: I wasn't able to find something about xsd order in the spec. We can plan an implementation of such improvement which will allow to put schemas in default order for the future releases.

Tomas-Kraus commented 12 years ago

@glassfishrobot Commented mmaxey said: I understand you have many issues to work and may want to think of this as an enhancement request. Let me make an argument for why this bug is very important to me.

I work with 300-400 XSDs where the build of these has been automated. This automation relies on being able to specify the list of XSDs by the directory name and/or in any order. Because of this bug, I must now insert some hacks into the automation that accounts for ordering. These hacks are going to be numerous because many our XSDs follow the pattern of the attached examples due to their high degree of interdependency.

Thank you for your assistance and thank you for considering my impact when assigning a priority to resolving this issue.

Tomas-Kraus commented 8 years ago

@glassfishrobot Commented newtopian said: I have a very similar issue here where I’m using the maven-jaxb2-plugin to generate code from xsd files.

I was able to track down the problem to namespace resolution. Basically the files have to be presented in such way that the order of the files represents the order of dependencies. I would expect the namespace resolver to be able to use the files in parameter as it would a catalog and to iterate the whole collection before failing to resolve a namespace.

As it stands we could summarize the situation as such: "In order to get XJC to parse and resolve namespaces in the xsd files I must first parse and resolve the xsd files to determine namespace dependencies. Then build the file list accordingly before passing over to xjc"

When viewed like this, I would more consider this a bug than enhancement. This being said, getting this fixed is to me far more important than the categorization semantics.

The maven-jaxb2-plugin seems to use the lexicographical order of files as the order provided to xjc. More details on the issue I raised over there https://github.com/highsource/maven-jaxb2-plugin/issues/98

Should you need more info, details or repro-steps for this issue please let me know.

Thanks.

Tomas-Kraus commented 8 years ago

@glassfishrobot Commented newtopian said: Possibly related issues :

Tomas-Kraus commented 12 years ago

@glassfishrobot Commented File: jaxb.zip Attached By: mmaxey

Tomas-Kraus commented 12 years ago

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-906