001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2004 World Wide Web Consortium,
032 *
033 * (Massachusetts Institute of Technology, European Research Consortium for
034 * Informatics and Mathematics, Keio University). All Rights Reserved. This
035 * work is distributed under the W3C(r) Software License [1] in the hope that
036 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
037 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
038 *
039 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
040 */
041
042 package org.w3c.dom.ls;
043
044 /**
045 * <code>LSResourceResolver</code> provides a way for applications to
046 * redirect references to external resources.
047 * <p> Applications needing to implement custom handling for external
048 * resources can implement this interface and register their implementation
049 * by setting the "resource-resolver" parameter of
050 * <code>DOMConfiguration</code> objects attached to <code>LSParser</code>
051 * and <code>LSSerializer</code>. It can also be register on
052 * <code>DOMConfiguration</code> objects attached to <code>Document</code>
053 * if the "LS" feature is supported.
054 * <p> The <code>LSParser</code> will then allow the application to intercept
055 * any external entities, including the external DTD subset and external
056 * parameter entities, before including them. The top-level document entity
057 * is never passed to the <code>resolveResource</code> method.
058 * <p> Many DOM applications will not need to implement this interface, but it
059 * will be especially useful for applications that build XML documents from
060 * databases or other specialized input sources, or for applications that
061 * use URNs.
062 * <p ><b>Note:</b> <code>LSResourceResolver</code> is based on the SAX2 [<a href='http://www.saxproject.org/'>SAX</a>] <code>EntityResolver</code>
063 * interface.
064 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407'>Document Object Model (DOM) Level 3 Load
065 and Save Specification</a>.
066 */
067 public interface LSResourceResolver {
068 /**
069 * Allow the application to resolve external resources.
070 * <br> The <code>LSParser</code> will call this method before opening any
071 * external resource, including the external DTD subset, external
072 * entities referenced within the DTD, and external entities referenced
073 * within the document element (however, the top-level document entity
074 * is not passed to this method). The application may then request that
075 * the <code>LSParser</code> resolve the external resource itself, that
076 * it use an alternative URI, or that it use an entirely different input
077 * source.
078 * <br> Application writers can use this method to redirect external
079 * system identifiers to secure and/or local URI, to look up public
080 * identifiers in a catalogue, or to read an entity from a database or
081 * other input source (including, for example, a dialog box).
082 * @param type The type of the resource being resolved. For XML [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] resources
083 * (i.e. entities), applications must use the value
084 * <code>"http://www.w3.org/TR/REC-xml"</code>. For XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
085 * , applications must use the value
086 * <code>"http://www.w3.org/2001/XMLSchema"</code>. Other types of
087 * resources are outside the scope of this specification and therefore
088 * should recommend an absolute URI in order to use this method.
089 * @param namespaceURI The namespace of the resource being resolved,
090 * e.g. the target namespace of the XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
091 * when resolving XML Schema resources.
092 * @param publicId The public identifier of the external entity being
093 * referenced, or <code>null</code> if no public identifier was
094 * supplied or if the resource is not an entity.
095 * @param systemId The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], of the
096 * external resource being referenced, or <code>null</code> if no
097 * system identifier was supplied.
098 * @param baseURI The absolute base URI of the resource being parsed, or
099 * <code>null</code> if there is no base URI.
100 * @return A <code>LSInput</code> object describing the new input
101 * source, or <code>null</code> to request that the parser open a
102 * regular URI connection to the resource.
103 */
104 public LSInput resolveResource(String type, String namespaceURI,
105 String publicId, String systemId, String baseURI);
106
107 }
|