Polymorphism in XSD schema and JAXB classes

前端 未结 4 769
忘掉有多难
忘掉有多难 2021-01-31 10:01

I have an xml like this:


    
    
    

        
4条回答
  •  温柔的废话
    2021-01-31 10:27

    I found the answer with the help of Blaise Doughan's article here: http://bdoughan.blogspot.com/2010/11/jaxb-and-inheritance-using-xsitype.html

    This schema:

    
        
            
                
                    
                    
                    
                
            
        
    
        
            
        
    
        
            
                
                
            
        
    
        
            
                
                
            
        
    
        
            
                
                    
                
            
        
    
    
    

    combined with a binding file:

    
        
          
                
            
        
    
    

    Will give abstract and inherited classes as I described in the question. The binding file will change Jaxb's default method name from getDoLaundryOrWashCarOrTidyBedroom() to getTasks().

提交回复
热议问题