Cannot generate classes because no top-level elements with complex type where found

后端 未结 2 1830
后悔当初
后悔当初 2021-01-04 23:03

I am trying to create a class from a xsd file using the XSD.EXE tool. but for some reason i get this error.

Warning: cannot generate classes because n

2条回答
  •  感动是毒
    2021-01-04 23:53

    You XSD only defines a type (as Sergio also suggested). As such, it cannot be used for validation of XML, unless it is imported by another XSD . Likewise, other tools like xsd.exe will not be able to anything sensible with it.

    You can compare this with a C# library having an interface definition, but no implementation of the interface.

    You can fix this in a variety of ways. Considering your current code, I would suggest something along those lines:

    
    
    
        
            
                
                
                
                
                
                
            
        
    
        
    
    

    Though you may consider renaming the type name, to prevent confusion to readers. A common pattern is to suffix typenames with Type, in your case, DocumentIdentificationType.

    The code above is importable with xsd.exe without any problems.

提交回复
热议问题