jaxb
  1. jaxb
  2. JAXB-906

XJC Dependent on Order of XSDs Listed on Command Line

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.5
    • Fix Version/s: None
    • Component/s: xjc
    • Labels:
      None

      Description

      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:

      • A2.xsd imports B.xsd
      • B.xsd includes A.xsd
      • A2.xsd is in a distinct namespace from A.xsd and B.xsd (sharing the same namespace)

      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?

        Activity

        Hide
        Iaroslav Savytskyi added a comment -

        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.

        Show
        Iaroslav Savytskyi added a comment - 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.
        Hide
        mmaxey added a comment -

        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.

        Show
        mmaxey added a comment - 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.
        Hide
        Newtopian added a comment - - edited

        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.

        Show
        Newtopian added a comment - - edited 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.
        Hide
        Newtopian added a comment -
        Show
        Newtopian added a comment - Possibly related issues : https://java.net/jira/browse/JAXB-1025 https://java.net/jira/browse/JAXB-1016

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            mmaxey
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: