我以为我正确地创建了这个XSD,但是当我针对Visual Studio运行它来验证它时。它声称它找不到属性,尽管它们已在我的XSD文件中明确定义。我在这做错了什么?
这是我的XML:
<LetterFile>
<Letter RequestID="" Type="" CertifiedMail="">
<Account accountID="" interestBalance="" ACCOUNTNUMBER="" DATEDUE="" RecordDate="" accountNumberExternal="" amountDueEscrow="" amountDueFees="" AMOUNTDUELATECHARGESOTHER="" TotalPieDue="" TotallDue="" TotalLegalFeesDue="" amountDueInterest="" AMOUNTDUELATECHARGES=""
amountDueOther="" AMOUNTDUEFEESOTHER="" AMOUNTDUEPRINCIPALINTERESTESCROW="" autopayAccount="" BALCUSTOMER="" BALCUSTOMERORIGINAL="" balUnapplied="" bankLogoPath="" BANKID="" BANKNAME="" BANKNAMEORIGINAL="" BORROWERPRIMARY="" BORROWERSALLINLINE=""
ALLBORROWERSINLINE="" BORROWERSALLADDRESSESINLINE="" BANKSERVICING="" BANKANDSERVICINGNAMEWITHMERGER="" CONTACTADDRESS="" contactEmail="" CONTACTNAME="" CONTACTPHONE="" contactTitle="" DATE="" DATE_x002B_45="" DATEDUE_x002B_1="" DATEDUE_x002B_30=""
DATEOPENED="" DAY="" DAYSDELINQUENT="" dt="" DATELASTPAID="" foreclosureSheriffSaleDate="" INVESTORPHONE="" LETTERHEAD="" MONTH="" PAYMENTAMOUNT="" paymentAmountIncludingLateCharges="" promiseDateLast="" PROPERTYADDRESSINLINE="" propertyCity="" propertyState=""
propertyStreet="" propertyZip="" rate="" revolvingType="" soldMortgageDelqType="" totalDue="" YEAR="" DATEDUELAST="" LASTPAIDINSTALLMENT="" CUSTOM.ORIGINALBALANCE="" PrincipalOriginal="" PrincipalBalance="" NumberOfMonthsPastDue="" MONTHSDELINQUENT=""
INVESTORNAME="" CUSTOM.FEDERALLYRELATED="" Custom.LienPosition="" CUSTOM.BANKORIGINATING="" TOTALDUEMINUSUNAPPLIED="" CONTACTSIGNATURE="" MAILINGADDRESS="" MAILINGTITLE="" CUSTOM.ALLOWNERS="" CUSTOM.ALLOWNERSINLINE="" TOTALDUEPLUSLEGAL="" MAILINGCC=""
CUSTOM.PACREDITCOUNSELING="" ALLOWNERSADDRESSESNETBORROWERS="" ALLOWNERSNETBORROWERS="">
<PaymentHistory Count="" BeginningDate="" EndingDate="" NoHistoryMessage="">
<Payment EffectiveDate="" ProcessedDate="" Description="" PrincipalAmount="" InterestAmount="" TotalAmount="" />
</PaymentHistory>
<LoanActivity accountID="" dateProcessed="" amtAdjustment="" amtEscrow="" amtFee="" amtInsurance="" amtInterest="" amtLateCharge="" amtPartial="" amtPrincipal="" amtTotal="" amtUnapplied="" amtOther="">
<b customData="" />
</LoanActivity>
</Account>
</Letter>
</LetterFile>
这是我的XSD:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://fult.com/FFCLetters.xsd" elementFormDefault="qualified" xmlns="http://fult.com/FFCLetters.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attributeGroup name="AG_Address">
<xs:annotation>
<xs:documentation>
Property Address
</xs:documentation>
</xs:annotation>
<xs:attribute name="Address1" type="xs:string" use="required" />
<xs:attribute name="Address2" type="xs:string" use="optional" />
<xs:attribute name="City" type="xs:string" use="required" />
<xs:attribute name="State" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2" />
<xs:minLength value="2" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="ZIP" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
<xs:minLength value="5" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="CreditAuthority" use="optional" type="xs:string" />
</xs:attributeGroup>
<xs:attributeGroup name="AG_Person">
<xs:annotation>
<xs:documentation>
Property Owner Information
</xs:documentation>
</xs:annotation>
<xs:attribute name="Name" use="required" type="xs:string"></xs:attribute>
<xs:attribute name="TaxID" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="11" />
<xs:minLength value="9" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:complexType name="CT_Payment">
<xs:attribute name="ProcessedDate" type="xs:string" use="optional" />
<xs:attribute name="EffectiveDate" type="xs:string" use="required" />
<xs:attribute name="Description" type="xs:string" use="optional" />
<xs:attribute name="PrincipalAmount" type="xs:string" use="optional" />
<xs:attribute name="InterestAmount" type="xs:string" use="optional" />
<xs:attribute name="TotalAmount" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="CT_CreditCounselingAgency">
<xs:annotation>
<xs:documentation>
Current Credit Counseling Agency for Property Owner.
</xs:documentation>
</xs:annotation>
<xs:attribute name="Name" use="required" type="xs:string" />
<xs:attributeGroup ref="AG_Address" />
</xs:complexType>
<xs:complexType name="CT_CreditCounselingAgencies">
<xs:annotation>
<xs:documentation>
Possible Credit Counseling Agencies.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="CreditCounselingAgency" maxOccurs="unbounded" minOccurs="1" type="CT_CreditCounselingAgency" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="CT_PaymentHistory">
<xs:annotation>
<xs:documentation>
Property Owner Payment History.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Payment" type="CT_Payment" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="NoHistoryMessage" use="required" type="xs:string" />
<xs:attribute name="BeginningDate" use="required" type="xs:string" />
<xs:attribute name="EndingDate" use="required" type="xs:string" />
<xs:attribute name="Count" use="optional">
<xs:simpleType>
<xs:restriction base="xs:long">
<xs:minInclusive value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="Account">
<xs:annotation>
<xs:documentation>
Aggregation of Account Data pertaining to the Recipients of the Letter.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="PaymentHistory" type="CT_PaymentHistory" minOccurs="0" />
</xs:sequence>
<xs:attribute name="DateLastPaid" use="optional" type="xs:string" />
<xs:attribute name="BALCUSTOMERORIGINAL" use="optional" type="xs:string" />
<xs:attribute name="interestBalance" use="optional" type="xs:string" />
<xs:attribute name="ACCOUNTNUMBER" use="required" type="xs:string" />
<xs:attribute name="accountNumberExternal" use="optional" type="xs:string" />
<xs:attribute name="accountID" use="optional" type="xs:string" />
<xs:attribute name="RecordDate" use="optional" type="xs:string" />
<xs:attribute name="amountDueEscrow" use="optional" type="xs:string" />
<xs:attribute name="amountDueFees" use="optional" type="xs:string" />
<xs:attribute name="AMOUNTDUEFEESOTHER" use="optional" type="xs:string" />
<xs:attribute name="amountDueFeesLateChargesOther" use="optional" type="xs:string" />
<xs:attribute name="amountDueInterest" use="optional" type="xs:string" />
<xs:attribute name="AMOUNTDUELATECHARGES" use="optional" type="xs:string" />
<xs:attribute name="AMOUNTDUELATECHARGESOTHER" use="optional" type="xs:string" />
<xs:attribute name="amountDueOther" use="optional" type="xs:string" />
<xs:attribute name="amountDuePrincipal" use="optional" type="xs:string" />
<xs:attribute name="BALCUSTOMER " use="optional" type="xs:string" />
<xs:attribute name="amountDueTotal" use="optional" type="xs:string" />
<xs:attribute name="balUnapplied" use="optional" type="xs:string" />
<xs:attribute name="dateDue" use="optional" type="xs:string" />
<xs:attribute name="PAYMENTAMOUNT" use="optional" type="xs:string" />
<xs:attribute name="paymentAmountLast" use="optional" type="xs:string" />
<xs:attribute name="autopayAccount" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.ALLOWNERSINLINE" use="optional" type="xs:string" />
<xs:attribute name="ALLOWNERSADDRESSESNETBORROWERS" use="optional" type="xs:string" />
<xs:attribute name="revolvingType" use="optional" type="xs:string" />
<xs:attribute name="rate" use="optional" type="xs:string" />
<xs:attribute name="bankLogoPath" use="optional" type="xs:string" />
<xs:attribute name="BANKID" use="optional" type="xs:string" />
<xs:attribute name="BANKNAME" use="optional" type="xs:string" />
<xs:attribute name="BORROWERPRIMARY" use="optional" type="xs:string" />
<xs:attribute name="borrowersAll" use="optional" type="xs:string" />
<xs:attribute name="BORROWERSALLINLINE" use="optional" type="xs:string" />
<xs:attribute name="BORROWERSALLADDRESSESINLINE" use="optional" type="xs:string" />
<xs:attribute name="BORROWERSECONDARY" use="optional" type="xs:string" />
<xs:attribute name="brDischargeDate" use="optional" type="xs:string" />
<xs:attribute name="brDismissalDate" use="optional" type="xs:string" />
<xs:attribute name="brFilingDate" use="optional" type="xs:string" />
<xs:attribute name="CONTACTADDRESS" use="optional" type="xs:string" />
<xs:attribute name="contactEmail" use="optional" type="xs:string" />
<xs:attribute name="CONTACTNAME" use="optional" type="xs:string" />
<xs:attribute name="CONTACTPHONE" use="optional" type="xs:string" />
<xs:attribute name="CONTACTSIGNATURE" use="optional" type="xs:string" />
<xs:attribute name="contactTitle" use="optional" type="xs:string" />
<xs:attribute name="date" use="optional" type="xs:string" />
<xs:attribute name="dateOpened" use="optional" type="xs:string" />
<xs:attribute name="day" use="optional" type="xs:string" />
<xs:attribute name="daysDelinquent" use="optional" type="xs:string" />
<xs:attribute name="dt" use="optional" type="xs:string" />
<xs:attribute name="dtClosed" use="optional" type="xs:string" />
<xs:attribute name="flag" use="optional" type="xs:string" />
<xs:attribute name="foreclosureSheriffSaleDate" use="optional" type="xs:string" />
<xs:attribute name="investorAbbreviation" use="optional" type="xs:string" />
<xs:attribute name="investorID" use="optional" type="xs:string" />
<xs:attribute name="LetterHead" use="optional" type="xs:string" />
<xs:attribute name="lossMitDateReceived" use="optional" type="xs:string" />
<xs:attribute name="month" use="optional" type="xs:string" />
<xs:attribute name="paymentAmountIncludingLateCharges" use="optional" type="xs:string" />
<xs:attribute name="promiseDateLast" use="optional" type="xs:string" />
<xs:attribute name="propertyAddress" use="optional" type="xs:string" />
<xs:attribute name="propertyCity" use="optional" type="xs:string" />
<xs:attribute name="propertyState" use="optional" type="xs:string" />
<xs:attribute name="propertyStreet" use="optional" type="xs:string" />
<xs:attribute name="propertyZip" use="optional" type="xs:string" />
<xs:attribute name="soldMortgageDelqType" use="optional" type="xs:string" />
<xs:attribute name="TotalDue" use="optional" type="xs:string" />
<xs:attribute name="YEAR" use="optional" type="xs:string" />
<xs:attribute name="DATEDUELAST" use="optional" type="xs:string" />
<xs:attribute name="TotalDuePlusLegal" use="optional" type="xs:string" />
<xs:attribute name="TotalPieDue" use="optional" type="xs:string" />
<xs:attribute name="TotallDue" use="optional" type="xs:string" />
<xs:attribute name="TotalLegalFeesDue" use="optional" type="xs:string" />
<xs:attribute name="AMOUNTDUEPRINCIPALINTERESTESCROW" use="optional" type="xs:string" />
<xs:attribute name="LASTPAIDINSTALLMENT" use="optional" type="xs:string" />
<xs:attribute name="DateLPI" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.ORIGINALBALANCE" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.ALLOWNERSADDRESSESINLINE" use="optional" type="xs:string" />
<xs:attribute name="ALLBORROWERSADDRESSES" use="optional" type="xs:string" />
<xs:attribute name="ALLBORROWERSINLINE" use="optional" type="xs:string" />
<xs:attribute name="ALLBORROWERS" use="optional" type="xs:string" />
<xs:attribute name="ALLOWNERSNETBORROWERS" use="optional" type="xs:string" />
<xs:attribute name="BANKSERVICING" use="optional" type="xs:string" />
<xs:attribute name="BANKNAMEORIGINAL" use="optional" type="xs:string" />
<xs:attribute name="bankOriginating" use="optional" type="xs:string" />
<xs:attribute name="BANKANDSERVICINGNAMEWITHMERGER" use="optional" type="xs:string" />
<xs:attribute name="BalCustomerOriginal" use="optional" type="xs:string" />
<xs:attribute name="BalCustomer" use="optional" type="xs:string" />
<xs:attribute name="monthsDelinquent" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.FEDERALLYRELATED" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.LIENPOSITION" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.BANKORIGINATING" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.LOANACTIVITYHISTORY" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.PACREDITCOUNSELING" use="optional" type="xs:string" />
<xs:attribute name="DATE" use="optional" type="xs:string" />
<xs:attribute name="DATEDUE" use="optional" type="xs:string" />
<xs:attribute name="DATELASTPAID" use="optional" type="xs:string" />
<xs:attribute name="DATEOPENED" use="optional" type="xs:string" />
<xs:attribute name="DAY" use="optional" type="xs:string" />
<xs:attribute name="DAYSDELINQUENT" use="optional" type="xs:string" />
<xs:attribute name="DATECLOSING" use="optional" type="xs:string" />
<xs:attribute name="DATE_x002B_45" use="optional" type="xs:string" />
<xs:attribute name="DATEDUE_x002B_1" use="optional" type="xs:string" />
<xs:attribute name="DATEDUE_x002B_30" use="optional" type="xs:string" />
<xs:attribute name="INVESTORNAME" use="optional" type="xs:string" />
<xs:attribute name="INVESTORPHONE" use="optional" type="xs:string" />
<xs:attribute name="LETTERHEAD" use="optional" type="xs:string" />
<xs:attribute name="MONTH" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYADDRESS" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYCITY" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYSTATE" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYSTREET" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYZIP" use="optional" type="xs:string" />
<xs:attribute name="MAILINGCC" use="optional" type="xs:string" />
<xs:attribute name="PROPERTYADDRESSINLINE" use="optional" type="xs:string" />
<xs:attribute name="TOTALDUE" use="optional" type="xs:string" />
<xs:attribute name="totalDue" use="optional" type="xs:string" />
<xs:attribute name="MONTHSDELINQUENT" use="optional" type="xs:string" />
<xs:attribute name="MAILINGTITLE" use="optional" type="xs:string" />
<xs:attribute name="MAILINGADDRESS" use="optional" type="xs:string" />
<xs:attribute name="TOTALDUEPLUSLEGAL" use="optional" type="xs:string" />
<xs:attribute name="TOTALLEGALFEESDUE" use="optional" type="xs:string" />
<xs:attribute name="NUMBEROFMONTHSPASTDUE" use="optional" type="xs:string" />
<xs:attribute name="TOTALDUEMINUSUNAPPLIED" use="optional" type="xs:string" />
<xs:attribute name="PrincipalOriginal" use="optional" type="xs:string" />
<xs:attribute name="PrincipalBalance" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.LienPosition" use="optional" type="xs:string" />
<xs:attribute name="CUSTOM.ALLOWNERS" use="optional" type="xs:string" />
</xs:complexType>
<xs:complexType name="CT_Recipient">
<xs:attributeGroup ref="AG_Person" />
<xs:attributeGroup ref="AG_Address" />
</xs:complexType>
<xs:complexType name="CT_LoanActivity">
<xs:sequence>
<xs:element name="b" type="CT_CustomData" />
</xs:sequence>
<xs:attribute name="accountID" use="optional" type="xs:string" />
<xs:attribute name="dateProcessed" use="optional" type="xs:string" />
<xs:attribute name="amtAdjustment" use="optional" type="xs:string" />
<xs:attribute name="amtEscrow" use="optional" type="xs:string" />
<xs:attribute name="amtFee" use="optional" type="xs:string" />
<xs:attribute name="amtInsurance" use="optional" type="xs:string" />
<xs:attribute name="amtInterest" use="optional" type="xs:string" />
<xs:attribute name="amtLateCharge" use="optional" type="xs:string" />
<xs:attribute name="amtPartial" use="optional" type="xs:string" />
<xs:attribute name="amtPrincipal" use="optional" type="xs:string" />
<xs:attribute name="amtTotal" use="optional" type="xs:string" />
<xs:attribute name="amtUnapplied" use="optional" type="xs:string" />
<xs:attribute name="amtOther" use="optional" type="xs:string" />
</xs:complexType>
<xs:complexType name="CT_Recipients">
<xs:annotation>
<xs:documentation>
Recipients of the Letter.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Person" type="CT_Recipient" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Count" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_Property">
<xs:all>
<xs:element name="Owners" type="CT_Recipients" minOccurs="1" />
<xs:element name="CreditCounselingAgencies" type="CT_CreditCounselingAgencies" minOccurs="0" />
</xs:all>
<xs:attributeGroup ref="AG_Address" />
<xs:attribute name="ParcelID" type="xs:string" use="optional" />
<xs:attribute name="CountyName" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="CT_LetterFile">
<xs:sequence>
<xs:element name="Letter" type="CT_Letter" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Count" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CT_Letter">
<xs:all>
<xs:element name="Account" type="Account" minOccurs="1" />
<xs:element name="Property" type="CT_Property" minOccurs="1" />
<xs:element name="Recipients" type="CT_Recipients" minOccurs="1" />
<xs:element name="CustomData" type="CT_Custom" minOccurs="0" />
</xs:all>
<xs:attribute name="RequestID" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="CertifiedMail" type="xs:boolean" default="false" use="optional" />
<xs:attribute name="Type" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="CT_Custom">
<xs:all>
<xs:element name="CustomValues" type="CT_CustomData" minOccurs="0" />
</xs:all>
</xs:complexType>
<xs:complexType name="CT_CustomData">
<xs:sequence>
<xs:element name="CustomValue" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Value" type="xs:string" />
</xs:complexType>
</xs:schema>
答案 0 :(得分:0)
为了让它完全验证,我首先必须(a)为LetterFile添加元素声明,以及(b)获取实例文档和模式以使用相同的命名空间。一旦我完成了,我得到以下错误(来自Saxon):
Validation error on line 2 column 48 of test.xml:
Validating Letter//@RequestID: Value "" contravenes the minLength facet "1" of the type of
attribute RequestID
Validating /LetterFile[1]/Letter[1]
See http://www.w3.org/TR/xmlschema-2/#cvc-complex-type clause 3
Validation error on line 2 column 48 of test.xml:
Validating Letter//@CertifiedMail: The string "" cannot be cast to a boolean
Validating /LetterFile[1]/Letter[1]
See http://www.w3.org/TR/xmlschema-2/#cvc-complex-type clause 3
Validation error on line 9 column 92 of test.xml:
Attribute @NumberOfMonthsPastDue is not allowed on element <Account>
Validating /LetterFile[1]/Letter[1]/Account[1]
See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 3
Validation error on line 9 column 92 of test.xml:
Attribute @Custom.LienPosition is not allowed on element <Account>
Validating /LetterFile[1]/Letter[1]/Account[1]
See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 3
Validation error on line 12 column 80 of test.xml:
Validating PaymentHistory//@Count: Cannot convert zero-length string to an integer
Validating /LetterFile[1]/Letter[1]/Account[1]/PaymentHistory[1]
See http://www.w3.org/TR/xmlschema-2/#cvc-complex-type clause 3
Validation error on line 17 column 206 of test.xml:
In content of element <Account>: The content model does not allow element <LoanActivity>
to appear immediately after element <PaymentHistory>. No further elements are allowed at
this point.
Validating /LetterFile[1]/Letter[1]/Account[1]/LoanActivity[1]
See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 2.4
Validation error on line 2 column 48 of test.xml:
In content of element <Letter>: element <Property> is not present
Validating /LetterFile[1]/Letter[1]
See http://www.w3.org/TR/xmlschema-1/#cvc-model-group clause 3
Validation error on line 2 column 48 of test.xml:
In content of element <Letter>: element <Recipients> is not present
Validating /LetterFile[1]/Letter[1]
See http://www.w3.org/TR/xmlschema-1/#cvc-model-group clause 3