I m 试图将我XML的档案从XSD的档案中查实,并附有以下代码:
Source xmlFile = new StreamSource(fXmlFile);
SchemaFactory schemaFactory = SchemaFactory
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(new File("presentation.xsd"));
Validator validator = schema.newValidator();
try {
validator.validate(xmlFile);
System.out.println(xmlFile.getSystemId() + " is valid");
} catch (SAXException e) {
System.out.println(xmlFile.getSystemId() + " is NOT valid");
System.out.println("Reason: " + e.getLocalizedMessage());
}
我把我的XSD文件上载到这里,以显示:。
但是,当我执行我的法典时,我发现这一错误:
org.xml.sax.SAXParseException: s4s-att-not-allowed: Attribute maxOccurs cannot appear in element element .
问题是什么,我如何解决这一问题?