XMLSpy 2006 存在 BUG:minOccurs 检查不到位

版本:XMLSpy Enterprise Edition 2006
描述:在对 element 或 sequence 进行 minOccurs 检查时,出现失效现象。
发生过程:
 
给出如下两个文件:
testMinOccur.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="test">
        <xs:complexType>
            <xs:sequence minOccurs=" 2" maxOccurs="unbounded">
                <xs:element name="TestNode"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
 
testMinOccur.xml
<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi=[url]http://www.w3.org/2001/XMLSchema-instance[/url] xsi:noNamespaceSchemaLocation="testMinOccur.xsd">
    <TestNode/>
</test>
XMLSpy 中,把 testMinOccur.xsd 与 testMinOccur.xml 拷贝到同一个目录下,然后打开 testMinOccur.xml,按 F8 进行 Validate,
报告“This file is valid.”,文件是正确的。
 
但事实上,只有一个 TestNode,不符合 Schema 中 minOccurs="2" 的要求。
 
同样的内容,用 Xerces 来验证,报告:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'test' is not complete. One of '{TestNode}' is expected.
 at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
 at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
 at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
 at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.elementLocallyValidType(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.processElementContent(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
 at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
 at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.jaxp.validation.StreamValidatorHelper.validate(Unknown Source)
 at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
 at javax.xml.validation.Validator.validate(Unknown Source)
 at TestNew.main(TestNew.java:42)
结论:
 
  XMLSpy Enterprise Edition 2006 在处理 minOccurs 时出现了失效现象,是一个 BUG。
 

你可能感兴趣的:(xml,bug,休闲,XMLSPY,minOccurs)