Most visited

Recently visited

Added in API level 8

LSResourceResolver

public interface LSResourceResolver

org.w3c.dom.ls.LSResourceResolver


LSResourceResolver为应用程序提供了将引用重定向到外部资源的方法。

需要实现外部资源自定义处理的应用程序可以实现此接口,并通过设置连接到LSParserLSSerializerDOMConfiguration对象的“resource-resolver”参数来注册它们的实现。 它也可以是上注册DOMConfiguration附着在物体上Document是否支持“LS”功能。

然后, LSParser将允许应用程序在包含它们之前拦截任何外部实体,包括外部DTD子集和外部参数实体。 顶级文档实体永远不会传递给resolveResource方法。

许多DOM应用程序不需要实现此接口,但对于从数据库或其他专用输入源或使用URN的应用程序构建XML文档的应用程序来说,它尤其有用。

注意: LSResourceResolver基于SAX2 [ SAX ] EntityResolver接口。

另见 Document Object Model (DOM) Level 3 Load and Save Specification

Summary

Public methods

abstract LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)

允许应用程序解析外部资源。

Public methods

resolveResource

Added in API level 8
LSInput resolveResource (String type, 
                String namespaceURI, 
                String publicId, 
                String systemId, 
                String baseURI)

允许应用程序解析外部资源。
LSParser将在打开任何外部资源(包括外部DTD子集,DTD中引用的外部实体以及文档元素内引用的外部实体(但顶级文档实体不传递给此方法))之前调用此方法。 然后,应用程序可能会要求LSParser解析外部资源本身,它使用替代URI或使用完全不同的输入源。
应用程序编写者可以使用此方法将外部系统标识符重定向到安全和/或本地URI,在目录中查找公共标识符或从数据库或其他输入源(包括例如对话框)读取实体, 。

Parameters
type String: The type of the resource being resolved. For XML [XML 1.0] resources (i.e. entities), applications must use the value "http://www.w3.org/TR/REC-xml". For XML Schema [XML Schema Part 1] , applications must use the value "http://www.w3.org/2001/XMLSchema". Other types of resources are outside the scope of this specification and therefore should recommend an absolute URI in order to use this method.
namespaceURI String: The namespace of the resource being resolved, e.g. the target namespace of the XML Schema [XML Schema Part 1] when resolving XML Schema resources.
publicId String: The public identifier of the external entity being referenced, or null if no public identifier was supplied or if the resource is not an entity.
systemId String: The system identifier, a URI reference [IETF RFC 2396], of the external resource being referenced, or null if no system identifier was supplied.
baseURI String: The absolute base URI of the resource being parsed, or null if there is no base URI.
Returns
LSInput A LSInput object describing the new input source, or null to request that the parser open a regular URI connection to the resource.

Hooray!