繁体   English   中英

使用SAXParser在S3中读取XML文件

[英]Read XML file in S3 using SAXParser

我需要使用SAXParser读取位于S3中的xml文件。 我找到了很多关于如何在S3中读取法线的例子,但没有任何与我的问题有关的材料。

我使用SAXParser的原因是因为我需要验证XML文件。 以下是验证本地xml文件的代码示例。

Source schemaFile = new StreamSource(entitiesScriptSchema);
System.out.println(path);
Source xmlFile = new StreamSource(new File(path));
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemaFile);
Validator validator = schema.newValidator();
validator.validate(xmlFile);

您将通过以下方式获得S3对象的InputStream

InputStream s3stream = s3Client.getObject("bucket", "key").getObjectContent();

然后,您应该能够像任何其他Java InputStream一样将InputStream传递给SAX Parser。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM