XSD - 数据类型丢失

发布于 2024-10-25 03:07:58 字数 3385 浏览 1 评论 0原文

我有两个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨洒年华 2024-11-01 03:07:58

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

必须

  • 通常,当您想在另一种模式中使用来自一种模式的类型时,如果目标命名空间,则 则导入相同
  • 包含它如果目标命名空间不同,

Disclaimer: I don't know xsd.exe.

Generally when you want to use types from one schema in another you have to

  • include it if the target namespaces are the same
  • import it if the target namespaces are different
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文