[英]Error when generating a class from xsd schema file
我正在嘗試從xsd架構生成一個類,但我收到以下錯誤消息:
警告:無法生成類,因為找不到具有復雜類型的頂級元素。
我的xsd文件看起來像這樣:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="MonitoringConfiguration"
targetNamespace="urn:MonitoringConfiguration-1.0"
elementFormDefault="qualified"
xmlns="urn:MonitoringConfiguration-1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="MonitoringConfiguration">
<xs:sequence>
<xs:element name="Machine" type="Machine" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Machine">
<xs:sequence>
<xs:element name="Component" type="Component" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Component">
<xs:attribute name="Name" type="xs:string" use="required"/>
<xs:attribute name="Type" type="xs:string" use="optional"/>
</xs:complexType>
</xs:schema>
我正在使用以下命令行生成類:
xsd MonitoringConfiguration.xsd /languages:CS /Classes
注意我已經定義了一個復雜類型的頂級元素(MonitoringConfiguration)。
怎么了?
謝謝
您已定義頂級復雜類型 - 但沒有頂級元素 。
你需要添加:
<xs:element name="MonitoringConfigurationElement"
type="MonitoringConfiguration" />
然后一切都應該沒問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.