我使用SchemaFactory生成Schema,如下所示
final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
InputStream stream1 = new FileInputStream("Test1.xsd");
InputStream stream2 = new FileInputStream("Test2.xsd");
StreamSource[] sourceArray = new StreamSource[2];
sourceArray[0] = new StreamSource(stream1);
sourceArray[1] = new StreamSource(stream2);
InputStream test = new FileInputStream("requestcontroller-webapp.xml");
Source testxml = new StreamSource(test);
Schema schema = null;
schema = sf.newSchema(sourceArray);
System.out.println("Schema creation successful");
我的一个xsd遇到了导致上述代码抛出的问题 -
org.xml.sax.SAXParseException; lineNumber:1; columnNumber:1; prolog中不允许使用内容。
现在问题本身不是例外,因为我可以检查xsd并解决问题。但是如果xsds的数量很大,那么我们有什么方法可以获得xsd的名称吗?因为异常消息没有描述它。