通常,使用 xsd.exe 时无法自定义生成的类的名称 - 与其他地方可用的机制不同,例如 JAXB 用户通过自定义 JAXB 绑定文件。
但是,对于 xsd.exe,生成的类名取决于创作风格。您所描述的内容是在创作风格符合“俄罗斯娃娃”时生成的,即如下:
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Students">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Student">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Department">
<xsd:complexType>
<xsd:attribute name="Id" type="xsd:unsignedByte" use="required" />
<xsd:attribute name="Name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="Name" type="xsd:string" use="required" />
<xsd:attribute name="RollNo" type="xsd:unsignedByte" use="required" />
<xsd:attribute name="Address" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
如果您将其样式更改为不同的样式(这称为威尼斯式百叶窗):
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Students" type="Students"/>
<xsd:complexType name="Students">
<xsd:sequence>
<xsd:element name="Student" type="Student"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Student">
<xsd:sequence>
<xsd:element name="Department" type="Department"/>
</xsd:sequence>
<xsd:attribute name="Name" type="xsd:string" use="required"/>
<xsd:attribute name="RollNo" type="xsd:unsignedByte" use="required"/>
<xsd:attribute name="Address" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="Department">
<xsd:attribute name="Id" type="xsd:unsignedByte" use="required"/>
<xsd:attribute name="Name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>
您将生成这些类: