我有一个看起来像这样的 XML
<?xml version="1.0" encoding="UTF-8"?>
<!-- FCT Automated Data Transfer Configuration -->
<config_info>
<!--First Server -->
<transfer_configuration ID="1">
<target_info>
<connection_string>Data Source=xyz;Initial Catalog=abc; User id=123; Password=Welcome1;</connection_string>
<table_name>t1234</table_name>
</target_info>
<source_info>
<access_file_path>Provider= Microsoft Office 12.0 Access Database Engine OLE DB Provider ; Data Source=C:\Data\Data.accdb</access_file_path>
<table_name>Data</table_name>
</source_info>
<transfer_interval_hours>240</transfer_interval_hours>
<retry_interval_minutes>100</retry_interval_minutes>
<transfer_interval_hours>0</transfer_interval_hours>
<field_map>
<Field source="Test_DateTime" target="Test_DateTime" />
<Field source="UUT_SlotNumber" target="UUT_SlotNumber" />
<Field source="System_ID" target="System_ID" />
</field_map>
<failure_notification>
<email_address_list>
<email_address>bob@abc.com</email_address>
<email_address>orson@abc.net</email_address>
<email_address>FrankieJ@abcd.com</email_address>
</email_address_list>
<email_subject>Automated Data Transfer Failure</email_subject>
<email_body>
Automatic mail.
</email_body>
</failure_notification>
</transfer_configuration>
<!--A Second Server-->
<transfer_configuration ID="more_unique_id">
<!-- ... remaining config information... -->
</transfer_configuration>
</config_info>
以及我要验证 xml 的 xsd 架构。架构是
<xsd:schema xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>
<xsd:complexType name=“DatabaseInfoType”>
<xsd:sequence>
<xsd:choice>
<xsd:element name=“connection_string” type=“string” />
<xsd:element name=“access_file_path” >
<xsd:simpleType>
<xsd:restriction base=“xsd:string”>
<xsd:pattern value=“([C-Z]:)|(\\)\\[^%*?\|]+” />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:choice>
<xsd:element name=“table_name” type=“string” />
</xsd:sequence>
<xsd:attribute name=“ID” type=“string” use=“required” />
</xsd:complexType>
<xsd:complexType name=“FieldMapType”>
<xsd:sequence>
<xsd:element name=“field” maxOccurs=“unbounded”>
</xsd:element>
</xsd:sequence>
<xsd:attribute name=“source” type=“xsd:NMTOKEN” use=“required” />
<xsd:attribute name=“target” type=“xsd:NMTOKEN” use=“required” />
<xsd:attribute name=“key” type=“xsd:boolean” />
</xsd:complexType>
<xsd:complexType name=“PeriodIntervalsType”>
<xsd:sequence>
<xsd:element name=“transfer_interval_hours” >
<xsd:simpleType>
<xsd:restriction base=“xsd:positiveInteger”>
<xsd:maxInclusive value=“240” />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name=“retry_interval_minutes” >
<xsd:simpleType>
<xsd:restriction base=“xsd:positiveInteger”>
<xsd:maxInclusive value=“100” />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name=“initial_interval_minutes” >
<xsd:simpleType>
<xsd:restriction base=“xsd:positiveInteger”>
<xsd:maxInclusive value=“100” />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=“FailureNotificationType”>
<xsd:sequence>
<xsd:element name=“email_to”>
<xsd:simpleType>
<xsd:restriction base=“xsd:string”>
<xsd:pattern value=“([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})” />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name=“email_subject” type=“string” />
<xsd:element name=“email_body” type=“string” />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=“TransferConfigType” >
<xsd:sequence>
<xsd:element name=“target_info” type=“DatabaseInfoType” />
<xsd:element name=“source_info” type=“DatabaseInfoType” />
<xsd:element name=“intervals” type=“PeriodIntervalsType” />
<xsd:element name=“field_map” type=“FieldMapType” />
<xsd:element name=“failure_notification” type=“FailureNotificationType” />
</xsd:sequence>
</xsd:complexType>
<xsd:element name=“config_info”>
<xsd:complexType>
<xsd:sequence>
<xsd:element name=“transfer_configuration” type=“TransferConfigType” maxOccurs=“unbounded” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
但是当我执行命令时
xmlFile.Validate(ConfigValHandler),我收到错误,因为“类型'字符串'未声明,或者不是简单类型。”
ConfigValHandler 是 XML 验证的错误处理程序。我无法找到解决方案。