Source for org.w3c.dom.ls.LSResourceResolver

   1: /*
   2:  * Copyright (c) 2004 World Wide Web Consortium,
   3:  *
   4:  * (Massachusetts Institute of Technology, European Research Consortium for
   5:  * Informatics and Mathematics, Keio University). All Rights Reserved. This
   6:  * work is distributed under the W3C(r) Software License [1] in the hope that
   7:  * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
   8:  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   9:  *
  10:  * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
  11:  */
  12: 
  13: package org.w3c.dom.ls;
  14: 
  15: /**
  16:  *  <code>LSResourceResolver</code> provides a way for applications to 
  17:  * redirect references to external resources. 
  18:  * <p> Applications needing to implement custom handling for external 
  19:  * resources can implement this interface and register their implementation 
  20:  * by setting the "resource-resolver" parameter of 
  21:  * <code>DOMConfiguration</code> objects attached to <code>LSParser</code> 
  22:  * and <code>LSSerializer</code>. It can also be register on 
  23:  * <code>DOMConfiguration</code> objects attached to <code>Document</code> 
  24:  * if the "LS" feature is supported. 
  25:  * <p> The <code>LSParser</code> will then allow the application to intercept 
  26:  * any external entities, including the external DTD subset and external 
  27:  * parameter entities, before including them. The top-level document entity 
  28:  * is never passed to the <code>resolveResource</code> method. 
  29:  * <p> Many DOM applications will not need to implement this interface, but it 
  30:  * will be especially useful for applications that build XML documents from 
  31:  * databases or other specialized input sources, or for applications that 
  32:  * use URNs. 
  33:  * <p ><b>Note:</b>  <code>LSResourceResolver</code> is based on the SAX2 [<a href='http://www.saxproject.org/'>SAX</a>] <code>EntityResolver</code> 
  34:  * interface. 
  35:  * <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
  36: and Save Specification</a>.
  37:  */
  38: public interface LSResourceResolver {
  39:     /**
  40:      *  Allow the application to resolve external resources. 
  41:      * <br> The <code>LSParser</code> will call this method before opening any 
  42:      * external resource, including the external DTD subset, external 
  43:      * entities referenced within the DTD, and external entities referenced 
  44:      * within the document element (however, the top-level document entity 
  45:      * is not passed to this method). The application may then request that 
  46:      * the <code>LSParser</code> resolve the external resource itself, that 
  47:      * it use an alternative URI, or that it use an entirely different input 
  48:      * source. 
  49:      * <br> Application writers can use this method to redirect external 
  50:      * system identifiers to secure and/or local URI, to look up public 
  51:      * identifiers in a catalogue, or to read an entity from a database or 
  52:      * other input source (including, for example, a dialog box). 
  53:      * @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 
  54:      *   (i.e. entities), applications must use the value 
  55:      *   <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>]
  56:      *   , applications must use the value 
  57:      *   <code>"http://www.w3.org/2001/XMLSchema"</code>. Other types of 
  58:      *   resources are outside the scope of this specification and therefore 
  59:      *   should recommend an absolute URI in order to use this method. 
  60:      * @param namespaceURI  The namespace of the resource being resolved, 
  61:      *   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>]
  62:      *    when resolving XML Schema resources. 
  63:      * @param publicId  The public identifier of the external entity being 
  64:      *   referenced, or <code>null</code> if no public identifier was 
  65:      *   supplied or if the resource is not an entity. 
  66:      * @param systemId  The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], of the 
  67:      *   external resource being referenced, or <code>null</code> if no 
  68:      *   system identifier was supplied. 
  69:      * @param baseURI  The absolute base URI of the resource being parsed, or 
  70:      *   <code>null</code> if there is no base URI. 
  71:      * @return  A <code>LSInput</code> object describing the new input 
  72:      *   source, or <code>null</code> to request that the parser open a 
  73:      *   regular URI connection to the resource. 
  74:      */
  75:     public LSInput resolveResource(String type, 
  76:                                    String namespaceURI, 
  77:                                    String publicId, 
  78:                                    String systemId, 
  79:                                    String baseURI);
  80: 
  81: }