【发布时间】:2017-03-10 12:20:06
【问题描述】:
我正在尝试使用过滤器验证架构。问题是它无法找到父 .xsd 内的标记中提到的依赖 .xsd。 我也使用了 resourceResolver-ref,但仍然面临同样的问题。这是示例配置和类文件。
<mulexml:schema-validation-filter schemaLocations="${app.home}/sample.xsd" returnResult="false" ref="classpathResourceResolver" name="sample_schema_Validation" doc:name="Schema Validation" />
package org.test.util;
import java.io.IOException;
import java.io.InputStream;
import org.apache.xerces.dom.DOMInputImpl;
import org.mule.util.IOUtils;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
public class ClasspathResourceResolver implements LSResourceResolver {
@Override
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
try {
InputStream resource = IOUtils.getResourceAsStream(systemId, getClass());
return new DOMInputImpl(publicId, systemId, baseURI, resource, null);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
我在这里很困惑如何传递引用来加载我的外部资源(依赖 xsd)? 请帮忙!!
【问题讨论】: