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