XSD: Adding attributes to strongly-typed “simple” elements

后端 未结 3 2026
Happy的楠姐
Happy的楠姐 2020-12-30 04:50

Is there some sensible way to have elements with strongly-typed simple-types and also attributes?

Okay, I have an XSD schema which has a million (er, hundred) elemen

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 05:10

    It's not entirely clear which aspect of the manual solution you regard as horrible; if it's the idea of having to define n different types just because they will need to extend n different base types, then you're stuck.

    If it's the idea of having to have n different declarations for the format and isVisible attributes, then you might find it less horrible to use a named attribute group to hold those definitions:

    
      
      
    
    

    The declarations of the various complex types you need remain repetitive but are now slightly less verbose:

    
      
        
          
        
      
    
    
      
        
          
        
      
    
    
      
        
          
        
      
    
    

    And the declarations of your elements are now slightly simpler than in your 'ideal' case:

    
    
    
    

提交回复
热议问题