开发者

XSD - The datatype is missing

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 wh开发者_StackOverflowen defining the namespaces.

What am I doing wrong? Any help would be greatly appreciated.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜