我有两个 xml 模式文件 (xsd)。一个定义了一个名为“Error”的数据类型,第二个引用它。
以下是模式:
CreateFolderResult.xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="CreateFolderResult"
targetNamespace="http://schemas.microsoft.com/sharepoint/soap/dws/"
elementFormDefault="qualified"
xmlns="http://schemas.microsoft.com/sharepoint/soap/dws/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/dws/"
>
<s:element name="CreateFolderResult">
<s:complexType>
<s:choice>
<s:element name="Result"/>
<s:element name="Error" type="Error"/>
</s:choice>
</s:complexType>
</s:element>
</xs:schema>
错误.xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Error"
targetNamespace="http://schemas.microsoft.com/sharepoint/soap/dws/"
elementFormDefault="qualified"
xmlns="http://schemas.microsoft.com/sharepoint/soap/dws/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/dws/"
>
<xs:simpleType name="ErrorTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="ServerFailure"/>
<xs:enumeration value="Failed"/>
<xs:enumeration value="NoAccess"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Error">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="ErrorTypes">
<xs:attribute name="ID">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="14"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="AccessUrl" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
这些模式文件来自此 PDF:MS-DWSS
当我尝试从它们生成 C# 类时,我收到一条错误消息,提示“缺少数据类型‘http://schemas.microsoft.com/sharepoint/soap/dws/:Error’。
我用谷歌搜索了它,并尝试了几种正确使用 xsd.exe 的方法,但仍然出现相同的错误。
我使用的命令是“xsd.exe /c CreateFolderResult.xsd Error.xsd”。
我还创建了这个“安装程序”:
<xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'>
<generateClasses language='CS' namespace='MyNamespace'>
<schema>CreateFolderResult.xsd</schema>
<schema>Error.xsd</schema>
</generateClasses>
</xsd>
并尝试运行:“xsd.exe /p:Installer.xsd /c”但也没有工作。我相信我在定义命名空间时做错了什么。
我究竟做错了什么?任何帮助将不胜感激。