2015-06-24 78 views
0

首先,我習慣了一個xsd/xml驗證器來檢查我的xsd是否對我編譯時沒有任何錯誤的xml文件起作用。我想引用我的XML文件中的XSD文件和這樣做是這樣的:無法找到元素的模式信息

<?xml version="1.0" encoding="utf-8"?> 
<Families xmlns="C:\workspace\XMLApplication\XMLApplication\XML" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="C:\workspace\XMLApplication\XMLApplication\XML Family.xsd"> 
    //other xml elements here. 
</Families> 

我的XSD內是這樣的:

<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

這是我得到的截圖。我在網上查找了很多解決方案,但其中大多數並沒有真正涉及到這個具體案例。

有,爲什麼這些訊息不斷想出任何主要原因?它會與xsd設計有關嗎?如果它是一個XSD的問題,你想看看完整的XSD文件,那就是:

<?xml version="1.0" encoding="utf-8"?> 
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <xsd:element name="Families" > 
     <xsd:complexType> 
     <xsd:sequence>    
      <xsd:element name="Family" minOccurs="1" maxOccurs="unbounded"> 
       <xsd:complexType> 
        <xsd:sequence> 
         <xsd:element name="FamilyID" type="xsd:int" minOccurs="1" maxOccurs="1"/> 

         <xsd:element name="PostalAddress" minOccurs="0"> 
          <xsd:complexType> 
          <xsd:sequence> 
           <xsd:element name="MailingAddress1" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="MailingAddress2" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="MailingCity" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="MailingPostCode" type="xsd:string" minOccurs="0"/>      
          </xsd:sequence> 
          </xsd:complexType> 
         </xsd:element>   

         <xsd:element name="ClientAddress" minOccurs="1" maxOccurs="1"> 
          <xsd:complexType> 
          <xsd:sequence> 
           <xsd:element name="HomeAddress1" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="HomeAddress2" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="HomeCity" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="HomePostcode" type="xsd:string" minOccurs="0"/>      
          </xsd:sequence> 
          </xsd:complexType> 
         </xsd:element> 

         <xsd:element name="Family_Client" minOccurs="1" maxOccurs="10"> 
          <xsd:complexType> 
          <xsd:sequence> 
           <xsd:element name="ClientID" type="xsd:int" /> 
           <xsd:element name="Title" type="Title" minOccurs="0"/> 
           <xsd:element name="FirstName" type="xsd:string" /> 
           <xsd:element name="LastName" type="xsd:string" /> 
           <xsd:element name="MiddleName" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="PreferredName" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Email" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Gender" type="Gender" minOccurs="0" /> 
           <xsd:element name="Dob" type="xsd:date" minOccurs="0" /> 
           <xsd:element name="HomePhone" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="MobilePhone" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="BusinessPhone" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="WorkEmail" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Fax" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Smoker" type="YesOrNo" minOccurs="0" /> 
           <xsd:element name="BestTimeToCall" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Occupation" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Employer" type="xsd:string" minOccurs="0" /> 
           <xsd:element name="Industry" type="xsd:string" minOccurs="0" /> 
          </xsd:sequence> 

          </xsd:complexType> 
         </xsd:element> 

            <xsd:element name="Loan" minOccurs="1" maxOccurs="unbounded"> 
             <xsd:complexType> 
             <xsd:sequence> 
              <xsd:element name="LenderName" type="LenderName" /> 
              <xsd:element name="LoanStatus" type="LoanStatus" /> 
              <xsd:element name="LoanReferenceNumber" type="xsd:string" minOccurs="0" /> 
              <xsd:element name="DateCreated" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="DateSettled" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="DateSubmitted" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="ApprovalDate" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="DateDeclined" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="DateWithdrawn" type="xsd:date" minOccurs="0" /> 
              <xsd:element name="DatePreApproved" type="xsd:date" minOccurs="0"/> 
              <xsd:element name="DatePreApprovalExpiry" type="xsd:date" minOccurs="0"/> 
              <xsd:element name="DeferralReviewDate" type="xsd:date" minOccurs="0"/> 
              <xsd:element name="DateCancelled" type="xsd:date" minOccurs="0"/> 

              <xsd:element name="Loan_Structure" minOccurs="0" maxOccurs="10"> 
              <xsd:complexType> 
               <xsd:sequence> 
               <xsd:element name="LoanTerm" type="InterestTerm" minOccurs="0"/> 
               <xsd:element name="InterestOnlyTerm" type="InterestTerm" minOccurs="0"/> 
               <xsd:element name="FixedRateTerm" type="InterestTerm" minOccurs="0"/> 
               <xsd:element name="FixedRateExpiryDate" type="xsd:date" minOccurs="0"/> 
               <xsd:element name="InterestRate" type="xsd:decimal" minOccurs="0"/> 
               <xsd:element name="Amount" type="xsd:decimal" minOccurs="0"/> 
               <xsd:element name="LoanStructureType" type="LoanStructureType" minOccurs="0"/> 
               <xsd:element name="RateType" type="RateType" minOccurs="0"/> 
               <xsd:element name="FrequencyName" type="FrequencyType" minOccurs="0"/> 
               <xsd:element name="PaymentAmount" type="xsd:decimal" minOccurs="0"/> 
               </xsd:sequence> 
              </xsd:complexType> 
              </xsd:element> 

              <xsd:element name="Family_Client" minOccurs="1" maxOccurs="20"> 
              <xsd:complexType> 
               <xsd:sequence> 
               <xsd:element name="ClientID" type="xsd:int" /> 
               </xsd:sequence> 
              </xsd:complexType> 
              </xsd:element> 

             </xsd:sequence> 
             </xsd:complexType> 
            </xsd:element> 

        </xsd:sequence> 
       </xsd:complexType> 
      </xsd:element> 


     </xsd:sequence> 
     </xsd:complexType> 
    </xsd:element> 

    <xsd:simpleType name="YesOrNo"> 
     <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Yes"/> 
     <xsd:enumeration value="No"/> 
     </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="Gender"> 
     <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Male"/> 
     <xsd:enumeration value="Female"/> 
     </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="Title"> 
     <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Mr"/> 
     <xsd:enumeration value="Mrs"/> 
     <xsd:enumeration value="Ms"/> 
     <xsd:enumeration value="Miss"/> 
     <xsd:enumeration value="Dr"/> 
     </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="RateType"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Fixed"/> 
     <xsd:enumeration value="Floating"/> 
     <xsd:enumeration value="Variable"/> 
     <xsd:enumeration value="TBA"/> 
    </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="LoanStructureType"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Principal and Interest"/> 
     <xsd:enumeration value="Interest Only"/> 
     <xsd:enumeration value="Revolving Credit"/> 
    </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="FrequencyType"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Weekly"/> 
     <xsd:enumeration value="Fortnightly"/> 
     <xsd:enumeration value="Monthly"/> 
    </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="InterestTerm"> 
    <xsd:restriction base="xsd:decimal"> 
     <xsd:minInclusive value="0"/> 
     <xsd:maxInclusive value="30"/> 
    </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="LoanStatus"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Conditional Approval"/> 
     <xsd:enumeration value="Construction Loan - Progressive Drawdown"/> 
     <xsd:enumeration value="Pre-Approved"/> 
     <xsd:enumeration value="Settled"/> 
     <xsd:enumeration value="Unconditional Approval"/> 
     <xsd:enumeration value="Cancelled"/> 
     <xsd:enumeration value="Declined"/> 
     <xsd:enumeration value="Discharged"/> 
     <xsd:enumeration value="Loan Repaid"/> 
     <xsd:enumeration value="Lost to Other Lender/Competitor"/> 
     <xsd:enumeration value="Not Proceeded With"/> 
     <xsd:enumeration value="On hold"/> 
     <xsd:enumeration value="Approved"/> 
     <xsd:enumeration value="Deferred"/> 
     <xsd:enumeration value="In Progress"/> 
     <xsd:enumeration value="Paid"/> 
     <xsd:enumeration value="Pre Submission"/> 
     <xsd:enumeration value="Submitted to Lender"/> 
     <xsd:enumeration value="Waiting for Documentation"/> 
    </xsd:restriction> 
    </xsd:simpleType> 

    <xsd:simpleType name="LenderName"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Abode Mortgages Limited"/> 
     <xsd:enumeration value="Access Home Loans Limited"/> 
     <xsd:enumeration value="AMBL"/> 
     <xsd:enumeration value="AMP"/> 
     <xsd:enumeration value="ANZ"/> 
     <xsd:enumeration value="Argosy"/> 
     <xsd:enumeration value="ASAP Finance Limited"/> 
     <xsd:enumeration value="ASB"/> 
     <xsd:enumeration value="Ascend Finance"/> 
     <xsd:enumeration value="Avanti Finance"/> 
     <xsd:enumeration value="Basecorp Finance"/> 
     <xsd:enumeration value="Bluestone"/> 
     <xsd:enumeration value="BNZ"/> 
     <xsd:enumeration value="CBS"/> 
     <xsd:enumeration value="Commix Group Limited"/> 
     <xsd:enumeration value="Cressida"/> 
     <xsd:enumeration value="DBR Limited"/> 
     <xsd:enumeration value="Family Finance"/> 
     <xsd:enumeration value="Freedom Mortgages Ltd"/> 
     <xsd:enumeration value="Freedom Mtgs"/> 
     <xsd:enumeration value="GE Money"/> 
     <xsd:enumeration value="Gem Hoam Loans"/> 
     <xsd:enumeration value="General Finance"/> 
     <xsd:enumeration value="Gold Band Finance"/> 
     <xsd:enumeration value="Home Trust Mortgages (Central West) Ltd"/> 
     <xsd:enumeration value="HSBC"/> 
     <xsd:enumeration value="Kiwibank"/> 
     <xsd:enumeration value="KMM H/O"/> 
     <xsd:enumeration value="Liberty"/> 
     <xsd:enumeration value="MARAC"/> 
     <xsd:enumeration value="Metro Money Ltd"/> 
     <xsd:enumeration value="Mortgage North"/> 
     <xsd:enumeration value="MTF"/> 
     <xsd:enumeration value="Mutual Finance Limit"/> 
     <xsd:enumeration value="National Bank"/> 
     <xsd:enumeration value="NBS"/> 
     <xsd:enumeration value="NZ Finance"/> 
     <xsd:enumeration value="NZ Guardian Trust"/> 
     <xsd:enumeration value="NZCU"/> 
     <xsd:enumeration value="NZF"/> 
     <xsd:enumeration value="Origin - ANZ"/> 
     <xsd:enumeration value="Other Lenders"/> 
     <xsd:enumeration value="Other Non Bank Lenders"/> 
     <xsd:enumeration value="Pacific Home Loans"/> 
     <xsd:enumeration value="Pacific Retail Finan"/> 
     <xsd:enumeration value="PFS"/> 
     <xsd:enumeration value="Pioneer"/> 
     <xsd:enumeration value="Presto"/> 
     <xsd:enumeration value="Property Equity Finanance"/> 
     <xsd:enumeration value="Property Finance Securities Limited"/> 
     <xsd:enumeration value="Public Trust"/> 
     <xsd:enumeration value="RESIMAC"/> 
     <xsd:enumeration value="SBS"/> 
     <xsd:enumeration value="SCF"/> 
     <xsd:enumeration value="Sentinel"/> 
     <xsd:enumeration value="Southern Cross Building Society"/> 
     <xsd:enumeration value="Southern Cross Finance Ltd"/> 
     <xsd:enumeration value="Sovereign"/> 
     <xsd:enumeration value="SuperBank"/> 
     <xsd:enumeration value="Tasman Mortgages"/> 
     <xsd:enumeration value="The Co-operative Bank"/> 
     <xsd:enumeration value="TSB"/> 
     <xsd:enumeration value="United Home Loans"/> 
     <xsd:enumeration value="Westpac"/> 
     <xsd:enumeration value="Wizard Homeloans"/> 
     <xsd:enumeration value="Other"/> 
    </xsd:restriction> 

    </xsd:simpleType> 


    </xsd:schema> 

回答

1

如果你真的希望你的XML文檔有C:\workspace\XMLApplication\XMLApplication\XML默認命名空間(由xmlns="C:\workspace\XMLApplication\XMLApplication\XML"上顯示根Families元素):

變化

<xsd:schema attributeFormDefault="unqualified" 
      elementFormDefault="qualified" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

<xsd:schema attributeFormDefault="unqualified" 
      elementFormDefault="qualified" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      targetNamespace="C:\workspace\XMLApplication\XMLApplication\XML"> 

,以便XSD的targetNamespace與您的XML文檔指定的默認名稱空間匹配。

0

xmlns =「...」定義了您的默認名稱空間。由於您沒有爲根元素名稱提供名稱空間後綴,因此該默認名稱空間必須與您導入/打算生成實例的xsd模式中定義的目標名稱空間匹配。

相關問題