相关疑难解决方法(0)

在jar文件中引用XSD架构

我有两个模式文件,一个从另一个导入.在Eclipse模式中执行代码时,但是找不到jar模式文件中的代码

这是代码

SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        SchemaFactory schemaFactory = SchemaFactory
                .newInstance("http://www.w3.org/2001/XMLSchema");
        try {
            factory.setSchema(schemaFactory.newSchema(new Source[] {
                    new StreamSource(getClass().getResource("Liso.xsd")
                            .getFile()),
                    new StreamSource(getClass().getResource("LisoXml.xsd")
                            .getFile()) }));
                this.saxParser = factory.newSAXParser();
        } catch (SAXException se) {
            System.out.println("SCHEMA : " + se.getMessage()); // problem in the XSD itself
        }
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误

SCHEMA : schema_reference.4: Failed to read schema document 'file:/C:/Tools/lib/LisoTools.jar!/com/xerox/liso/xml/Liso.xsd', because 1) could not find the do
cument; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. …
Run Code Online (Sandbox Code Playgroud)

java xsd jar

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

jar ×1

java ×1

xsd ×1