我需要xml來匹配XSD架構,但它不匹配。 XSD模式中可能有什麼錯誤?有些東西與xsi:type =「...」不符。我可能會錯過什麼。希望你能注意到什麼是錯的。我一直在嘗試使用在線xsd驗證並修復它,但不起作用。所以我放棄了,決定寫在這裏。非常感謝您的幫助。謝謝!xml不匹配xsd模式 - 爲什麼?
這裏是XML:
<?xml version="1.0" encoding="utf-8" ?>
<ValidatorList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<FieldValidator xsi:type="RequiredFieldValidator" PropertyName="BankTransactionNumber">
<Next xsi:type="AsciiValidator" />
</FieldValidator>
<FieldValidator xsi:type="RequiredFieldValidator" PropertyName="CurrencyIndicator">
<Next xsi:type="StringLengthValidator" MaxLength="3" MinLength="3">
<Next xsi:type="AlphaValidator" />
</Next>
</FieldValidator>
</ValidatorList>
XSD架構爲這個XML:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ValidatorList">
<xs:complexType>
<xs:sequence>
<xs:element name="FieldValidator" maxOccurs="unbounded" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="Next" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="Next" minOccurs="0">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="Next" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:byte" name="DecimalPlaces"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="MaxLength" use="optional"/>
<xs:attribute type="xs:byte" name="MinLength" use="optional"/>
<xs:attribute type="xs:string" name="AllowedValues" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:byte" name="MaxLength" use="optional"/>
<xs:attribute type="xs:byte" name="MinLength" use="optional"/>
<xs:attribute type="xs:byte" name="DefaultValue" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element type="xs:string" name="RegEx" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="PropertyName" use="optional"/>
<xs:attribute type="xs:byte" name="DefaultValue" use="optional"/>
<xs:attribute type="xs:string" name="TypeProperty" use="optional"/>
<xs:attribute type="xs:string" name="Regex" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
我得到這樣的錯誤消息:
Error - Line 4, 39: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 39; cvc-elt.4.2: Cannot resolve 'AsciiValidator' to a type definition for element 'Next'.
Error - Line 6, 87: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 87; cvc-elt.4.2: Cannot resolve 'RequiredFieldValidator' to a type definition for element 'FieldValidator'.
Error - Line 7, 72: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 72; cvc-elt.4.2: Cannot resolve 'StringLengthValidator' to a type definition for element 'Next'.
Error - Line 8, 41: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 41; cvc-elt.4.2: Cannot resolve 'AlphaValidator' to a type definition for element 'Next'.
那麼,您定義的「AsciiValidator」類型在哪裏?我無法在模式中看到。也許嘗試將所有'xsi:type'更改爲'FieldValidator'(您唯一定義的唯一一個)。 –
它是字符串類型。即時通訊不知道如何糾正xsd架構... – user235973457
'AsciiValidator'是一個字符串類型? –