Can Castor handle class generation from multiple XSDs importing from a base XSD?

前端 未结 2 623
臣服心动
臣服心动 2020-12-11 10:31

I have several XSDs that reuse the same entities. For example, both the XSDs for the ProductPurchaseRequest.xsd and ProductQuoteRequest.xsd both ha

2条回答
  •  被撕碎了的回忆
    2020-12-11 10:39

    So I was able to get the whole thing working using the JAXB reference implementation. The trick was to realise that the download from JAXB site is a downloader and not the actual libraries! Double-click to accept the licence and the libraries will download locally. Created a test folder (JAXB_TEST) and copied all the downloaded .jars to a lib subfolder. I put all my XSDs in XSD subfolder. After that I ran the following Ant build.xml file.

    
    
    
        
            
                
            
        
    
        
            
            
    
            
                
                  
        
    
        
            
            
    
            
        
    
        
            
            
            
           
    
    
    
    

    The only problem I had was that I had an xsd with a root tag called that anonymous extended the Product type to add a version attribute (which I always like to have on my root tag's) which was causing a name conflict for JAXB. So instead, I turned the anonymous type into a named type (i.e. TopLevelProduct) and set the root to that type and JAXB was happy with that.

提交回复
热议问题