我有以下代码,它是从资源流加载XSD的方法的一部分(即XSD是本地资源):
// Instantiate the registry of available DOM implementations.
DOMImplementationRegistry registry = null;
try {
registry = DOMImplementationRegistry.newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException e) {
LOG.fatal("Error instantiating DOM implementation registry", e);
return null;
}
// Get the DOM implementation for "LS" as we need this to be able to pass an input stream for parsing.
final DOMImplementationLS domLS = (DOMImplementationLS)registry.getDOMImplementation("LS 3.0");
// Set up the input stream for input to the parser.
final LSInput lsi = domLS.createLSInput();
lsi.setCharacterStream(new InputStreamReader(input));
// Load the schema from the input stream.
final XMLSchemaLoader loader = new XMLSchemaLoader();
final XSModel model = loader.load(lsi);
我尝试创建XSModel的最后一行始终为Java 7 Update 40+返回null,但对Java 7 Update 25及更早版本非常有效。
可能是什么原因,是否有解决方案?
我在Windows 7 64位上使用64位Java 7。