2011-03-18 190 views
0

我有兩個xml模式文件(xsd)。一個定義了一個名爲「Error」的數據類型,第二個指向它。XSD - 數據類型丟失

下面是模式:

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#類我得到一個錯誤說,「數據atype'http://schemas.microsoft.com/sharepoint/soap/dws/:Error'缺失。

我GOOGLE了它,我嘗試了幾種方法如何正確使用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」,但也不能工作。 我相信我在定義名稱空間時做錯了什麼。

我在做什麼錯? 任何幫助將不勝感激。

回答

1

聲明:我不知道xsd.exe。

一般來說,當你想從一個架構使用類型的另一個你不得不

  • include,如果目標命名空間是相同的
  • import,如果目標命名空間是不同的
+0

@musiKk 我把包括在架構的頂部,但沒有變化。 <?XML版本= 「1.0」 編碼= 「UTF-8」?> papaiatis 2011-03-21 08:21:34

+0

模式位置是無效的。 – musiKk 2011-03-21 08:33:51

+0

@musiKk模式位置如下:我最後的評論已被截斷,我應該怎麼輸入而不是它? – papaiatis 2011-03-21 10:12:39