【问题标题】:XSD - The datatype is missingXSD - 缺少数据类型
【发布时间】:2011-03-18 15:40:25
【问题描述】:

我有两个 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”但也没有工作。 我相信我在定义命名空间时做错了什么。

我做错了什么? 任何帮助将不胜感激。

【问题讨论】:

    标签: xml xsd xsd.exe


    【解决方案1】:

    免责声明:我不知道 xsd.exe。

    通常,当您想在另一个模式中使用来自一个模式的类型时,您必须这样做

    • include 如果目标命名空间相同,则为它
    • import 如果目标命名空间不同,则使用它

    【讨论】:

    • @musiKk 我将 include 放在架构的顶部,但没有更改。 schemas.microsoft.com/sharepoint/soap/dws/Error.xsd" />
    • 架构位置无效。
    • @musiKk 架构位置如下: 我的最后一条评论被截断了,我应该输入什么来代替它?
    • 如果您访问该 URL,您将看到一个错误。您必须提供通向该架构的有效地址。最简单的事情是您的模式彼此相邻。那么位置就是模式的名称(例如schemaLocation="Error.xsd")。
    • @musiKk 我找不到任何其他有效的 URL。它是在 Microsoft 编写的 PDF 中定义的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 2019-11-24
    • 2011-03-15
    • 1970-01-01
    相关资源
    最近更新 更多