URIResolver
은 참조를 확인할 수없는 경우 null
을 반환해야합니다. 이것에 의해, 기본의 리절버를 시험 할 수가 있습니다.
리졸버를 구성 할 때 다른 하나의 파라미터로 URIResolver
을 생성하면 리졸버 체인을 사용할 수 있습니다.
TransformerFactory tf;
tf.setURIResolver(new SomeOtherResolver());
tf.setURIResolver(new MyResolver(tf.getURIResolver());
public class MyResolver implements URIResolver {
public MyResolver(URIResolver nextInLine) {
this.nextInLine = nextInLine;
}
private URIResolver nextInLine;
public Source resolve(String href, String base) throws TransformerException {
...try to solve and return Source object...
return nextInLine; // instead of returning null on failure, return nextInLine
}
}
대안은 목록으로 리졸버의 체인을 설정할 수 리졸버를 작성하는 것이며, 비 null
응답이 반환 될 때까지 호출 유지하고, 그 다음을 반환합니다.