找不到元素的架构信息

时间:2015-06-24 03:05:09

标签: xml xsd

首先,我习惯使用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>

2 个答案:

答案 0 :(得分: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文档指定的默认命名空间匹配。

答案 1 :(得分:0)

的xmlns =&#34; ...&#34;定义默认命名空间。由于您没有为根元素名称提供名称空间后缀,因此该默认名称空间必须与您导入/打算生成实例的xsd模式中定义的目标名称空间匹配。