XSD - 数据类型丢失
我有两个 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>
Error.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' 丢失了。
google 搜索了它,并尝试了几种如何正确使用 xsd.exe 的方法,但仍然出现相同的错误。
我用 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”,但也不起作用。 我相信我在定义名称空间时做错了什么。
我做错了什么? 任何帮助将不胜感激。
I have two xml schema files (xsd). One defines a datatype called "Error", the second refers to it.
Here are the schemas:
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>
Error.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>
These schema files come from this PDF: MS-DWSS
When I try to generate C# classes from them I get an error saying that "The datatype 'http://schemas.microsoft.com/sharepoint/soap/dws/:Error' is missing.
I googled it, and I tried a couple ways how to use xsd.exe properly but still has the same error.
The command I'm using is "xsd.exe /c CreateFolderResult.xsd Error.xsd".
I also created this "installer":
<xsd xmlns='http://microsoft.com/dotnet/tools/xsd/'>
<generateClasses language='CS' namespace='MyNamespace'>
<schema>CreateFolderResult.xsd</schema>
<schema>Error.xsd</schema>
</generateClasses>
</xsd>
And tried to run: "xsd.exe /p:Installer.xsd /c" but didn't work either.
I believe I'm doing something wrong when defining the namespaces.
What am I doing wrong?
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:我不知道 xsd.exe。
必须
Disclaimer: I don't know xsd.exe.
Generally when you want to use types from one schema in another you have to