我需要 xml 来匹配 XSD 架构,但它不匹配。XSD 架构中可能有什么问题?xsi:type="..." 有问题。我可能会错过一些东西。希望你能注意到哪里出了问题。我一直在尝试使用 xsd validate online 并修复它,但不起作用。所以我放弃了,决定在这里写。非常感谢您的帮助。谢谢!
这是 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>
此 XML 的 XSD 架构:
<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'.