模式生成期间的SAXParseException不会给出无效的xsd名称

时间:2018-06-05 13:08:20

标签: java xml xsd sax saxparseexception

我使用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的名称吗?因为异常消息没有描述它。

0 个答案:

没有答案