how to force schema compiled classes to extend specific class outside schema

前端 未结 4 1152
逝去的感伤
逝去的感伤 2020-12-10 17:31

Need help with following situation: Users can generate their own data structures which are stored as JAXB-ready XSD sources like below:



        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 17:51

    I do not believe that there is an easy way to do this using JAXB itself. There are a number of customization options available that are not commonly known - read section 7 of JSR222 for details.

    If you have some control over the input schemas, then you might want to consider using XSLT to transform the schema. I believe that this can be done by using a javax.xml.transform.dom.DOMResult instance as the target of the transformation and using the output as a DOM tree (e.g., calling getNode() on the result) as the input to parseSchema. A basic transformation would be to replace:

    
      
    
    

    with something like:

    
      
        
          
        
      
    
    

    Of course this only works for the simple cases. If you already have inheritance in your schema files, then you will have to do some filtering in the XSLT that only applies this transform to types that do not already extend.

提交回复
热议问题