| 1 | /* |
|---|
| 2 | * JOMDoc - A Java library for OMDoc documents (http://omdoc.org/jomdoc). |
|---|
| 3 | * |
|---|
| 4 | * Original author Dimitar Misev <d.misev@jacobs-university.de> |
|---|
| 5 | * Web http://kwarc.info/dmisev/ |
|---|
| 6 | * Created Feb 4, 2010, 10:40:40 AM |
|---|
| 7 | * |
|---|
| 8 | * Filename $Id$ |
|---|
| 9 | * Revision $Revision$ |
|---|
| 10 | * Last modified on $Date$ |
|---|
| 11 | * by $Author$ |
|---|
| 12 | * |
|---|
| 13 | * Copyright (C) 2007,2008 the KWARC group (http://kwarc.info) |
|---|
| 14 | * Licensed under the GNU Public License v3 (GPL3). |
|---|
| 15 | * For other licensing contact Michael Kohlhase <m.kohlhase@jacobs-university.de> |
|---|
| 16 | */ |
|---|
| 17 | package org.omdoc.jomdoc.util.resolver; |
|---|
| 18 | |
|---|
| 19 | import java.io.InputStream; |
|---|
| 20 | import java.net.URI; |
|---|
| 21 | import javax.xml.transform.URIResolver; |
|---|
| 22 | import nu.xom.Document; |
|---|
| 23 | import nu.xom.Element; |
|---|
| 24 | import org.omdoc.jomdoc.lang.OMDocDocument; |
|---|
| 25 | import org.omdoc.jomdoc.lang.OMDocElement; |
|---|
| 26 | import org.omdoc.jomdoc.util.types.Pair; |
|---|
| 27 | import org.w3c.dom.ls.LSResourceResolver; |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * Throughout JOMDoc this interface is used to resolve URIs. |
|---|
| 31 | * <p> |
|---|
| 32 | * {@link LSResourceResolver} is used in RelaxNG schema validation of OMDoc |
|---|
| 33 | * Documents, while {@link URIResolver} is used in the XSLT transformation. |
|---|
| 34 | * |
|---|
| 35 | * @author <a href="mailto:d.misev@jacobs-university.de">Dimitar Misev</a> |
|---|
| 36 | */ |
|---|
| 37 | public interface JOMDocURIResolver extends URIResolver, LSResourceResolver { |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * @return a pair (A, B) where A is InputStream to location <code>href</code> |
|---|
| 41 | * with respect to <code>base</code>, and B is the absolute URI to A. |
|---|
| 42 | */ |
|---|
| 43 | Pair<? extends InputStream, URI> resolveInputStream(String href, String base) throws ResolveException; |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * @return the content at location <code>href</code> with respect to <code>base</code> |
|---|
| 47 | * as XOM Document. |
|---|
| 48 | */ |
|---|
| 49 | Document resolveDocument(String href, String base) throws ResolveException; |
|---|
| 50 | |
|---|
| 51 | /** |
|---|
| 52 | * @return the content at location <code>href</code> with respect to <code>base</code> |
|---|
| 53 | * as XOM Element. |
|---|
| 54 | */ |
|---|
| 55 | Element resolveElement(String href, String base) throws ResolveException; |
|---|
| 56 | |
|---|
| 57 | /** |
|---|
| 58 | * @return the content at location <code>href</code> with respect to <code>base</code> |
|---|
| 59 | * as OMDocDocument. |
|---|
| 60 | */ |
|---|
| 61 | OMDocDocument resolveOMDocDocument(String href, String base) throws ResolveException; |
|---|
| 62 | |
|---|
| 63 | /** |
|---|
| 64 | * @return the content at location <code>href</code> with respect to <code>base</code> |
|---|
| 65 | * as OMDocElement. |
|---|
| 66 | */ |
|---|
| 67 | OMDocElement resolveOMDocElement(String href, String base) throws ResolveException; |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * @return true if the the schema in the given <code>uri</code> is supported |
|---|
| 71 | * by this resolver, false if it's not or the uri doesn't have a schema part. |
|---|
| 72 | */ |
|---|
| 73 | boolean isSchemaSupported(String uri); |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * @return true if the the schema in the given <code>uri</code> is supported |
|---|
| 77 | * by this resolver, false if it's not or the uri doesn't have a schema part. |
|---|
| 78 | */ |
|---|
| 79 | boolean isSchemaSupported(String href, String base, boolean log); |
|---|
| 80 | } |
|---|