我正在尝试为 Xerces XML 验证设置功能。我很难找到/理解哪些功能SchemaFactory
对Validator
.
我有以下代码:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_US_URI);
factory.setFeature("http://xml.org/sax/features/validation", true);
Schema schema = factory.newSchema(mySchemaList);
Validator validator = schema.newValidator;
validator.setFeature("http://xml.org/sax/features/validation", true);
如果我执行上述操作,我会得到:
SAXNotRecognizedException: Feature 'http://xml.org/sax/features/validation
但是,如果我将 注释掉setFeature
,SchemaFactory
设置该功能适用于Validator
.
所以问题:
- 为什么我可以在 上设置该功能,
Validator
但不能在 上设置SchemaFactory
? - 我在哪里可以找到哪些功能适用于
Validator
和的文档SchemaFactory
?
仅供参考:SchemaFactory
我得到的是com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory
编辑
我尝试设置但没有成功的其他一些功能是:
http://xml.org/sax/features/namespaces
http://xml.org/sax/features/namespace-prefixes