如何将输入流转换为源?
2022-09-02 11:44:47
我想使用存储在设备上的 xsd 架构文件验证 xml 文档。以下是我的示例代码:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
// schema file on my device
InputStream isSchema = context.getResources().openRawResource(xsd_file);
// InputStream => Source conversion
Source schemaSource = ????
Schema schema = factory.newSchema(schemaSource);
Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
问题:如何将 InputStream 转换为 SchemaFactory::newSchema 方法所需的源代码?