Is there a way to deal with duplicate element definitions across multiple .xsd files in JAXB?

后端 未结 5 1986
予麋鹿
予麋鹿 2020-12-05 05:35

I have dozens and dozens .xsd files that I want to auto-generate code for. A couple of the files have duplicate names that clash when I try to generate all of t

5条回答
  •  無奈伤痛
    2020-12-05 05:38

    I have a half-way workaround solution to this, but it is very time intensive. I had to create a separate for every one of the files that has duplicate entries.

    
      
        jaxb-mac
        generate-sources
        
          generate
        
        
          true
          my.company.mac
          src/main/schema
          
            mac-3.4.xsd
          
        
      
      
        jaxb-stylesheet
        generate-sources
        
          generate
        
        
          true
          my.company.stylesheet
          src/main/schema
          
            mac-stylesheet-3.4.xsd
          
        
      
    

    The true is important or only the first will run and the rest will think that there is no need to run because I am generating into the same directory.

    I would still like a less labor intensive solution to deal with the duplicates.

    I think if I make the first master .xsd a separate module that builds into its own .jar file, I could then use the tag and have it skip generating the same duplicate elements over and over, since they are identical in definition.

    I have since decided to abandon XML if at all possible and JAXB completely. There are newer and better ways to parse XML and map it to objects as of this edit.

提交回复
热议问题