| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private static final String[] | |
| private final Map | |
| private static final StringManager | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | LocalResolver(Map<String, String>
mapping of well-known public identifiers to local
resources publicIds, Map<String, String> mapping of well-known system identifiers to local
resources systemIds, boolean are external resources blocked that are not
well-known blockExternal)Constructor providing mappings of public and system identifiers to local resources. |
| Modifier and Type | Method and Description |
|---|---|
| public InputSource | getExternalSubset(String
Identifies the document root element. This name comes
from a DOCTYPE declaration (where available) or from the actual
root element. name, String The document's base URI, serving as an additional
hint for selecting the external subset. This is always an absolute
URI, unless it is null because the XMLReader was given an InputSource
without one. baseURI)Implements org. Allows applications to provide an external subset for documents that don't explicitly define one. |
| public InputSource | resolveEntity(String
The public identifier of the external entity
being referenced, or null if none was supplied. publicId, String The system identifier of the external entity
being referenced. systemId)Implements org. Allow the application to resolve external entities. |
| public InputSource | resolveEntity(String
Identifies the external entity being resolved.
Either "[dtd]" for the external subset, or a name starting
with "%" to indicate a parameter entity, or else the name of
a general entity. This is never null when invoked by a SAX2
parser. name, String The public identifier of the external entity being
referenced (normalized as required by the XML specification), or
null if none was supplied. publicId, String The URI with respect to which relative systemIDs
are interpreted. This is always an absolute URI, unless it is
null (likely because the XMLReader was given an InputSource without
one). This URI is defined by the XML specification to be the one
associated with the "<" starting the relevant declaration. base, String The system identifier of the external entity
being referenced; either a relative or absolute URI.
This is never null when invoked by a SAX2 parser; only declared
entities, and any external subset, are resolved by such parsers. systemId)Implements org. Allows applications to map references to external entities into input sources, or tell the parser it should use conventional URI resolution. |
| blockExternal | back to summary |
|---|---|
| private final boolean blockExternal | |
| JAVA_EE_NAMESPACES | back to summary |
|---|---|
| private static final String[] JAVA_EE_NAMESPACES | |
| publicIds | back to summary |
|---|---|
| private final Map<String, String> publicIds | |
| sm | back to summary |
|---|---|
| private static final StringManager sm | |
| systemIds | back to summary |
|---|---|
| private final Map<String, String> systemIds | |
| LocalResolver | back to summary |
|---|---|
| public LocalResolver(Map<String, String> publicIds, Map<String, String> systemIds, boolean blockExternal) Constructor providing mappings of public and system identifiers to local resources. Each map contains a mapping from a well-known identifier to a URL for a local resource path. | |
| getExternalSubset | back to summary |
|---|---|
| public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException Implements org. Doc from org. Allows applications to provide an external subset for documents
that don't explicitly define one. Documents with DOCTYPE declarations
that omit an external subset can thus augment the declarations
available for validation, entity processing, and attribute processing
(normalization, defaulting, and reporting types including ID).
This augmentation is reported
through the This method can also be used with documents that have no DOCTYPE declaration. When the root element is encountered, but no DOCTYPE declaration has been seen, this method is invoked. If it returns a value for the external subset, that root element is declared to be the root element, giving the effect of splicing a DOCTYPE declaration at the end the prolog of a document that could not otherwise be valid. The sequence of parser callbacks in that case logically resembles this:
... comments and PIs from the prolog (as usual)
startDTD ("rootName", source.getPublicId (), source.getSystemId ());
startEntity ("[dtd]");
... declarations, comments, and PIs from the external subset
endEntity ("[dtd]");
endDTD ();
... then the rest of the document (as usual)
startElement (..., "rootName", ...);
Note that the InputSource gets no further resolution.
Implementations of this method may wish to invoke
Uses for this method include facilitating data validation when interoperating with XML processors that would always require undesirable network accesses for external entities, or which for other reasons adopt a "no DTDs" policy. Non-validation motives include forcing documents to include DTDs so that attributes are handled consistently. For example, an XPath processor needs to know which attributes have type "ID" before it can process a widely used type of reference. Warning Returning an external subset modifies the input document. By providing definitions for general entities, it can make a malformed document appear to be well formed.
| |
| resolveEntity | back to summary |
|---|---|
| public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException Implements org. Doc from org. Allow the application to resolve external entities. The parser will call this method before opening any external entity except the top-level document entity. Such entities include the external DTD subset and external parameter entities referenced within the DTD (in either case, only if the parser reads external parameter entities), and external general entities referenced within the document element (if the parser reads external general entities). The application may request that the parser locate the entity itself, that it use an alternative URI, or that it use data provided by the application (as a character or byte input stream). Application writers can use this method to redirect external system identifiers to secure and/or local URIs, to look up public identifiers in a catalogue, or to read an entity from a database or other input source (including, for example, a dialog box). Neither XML nor SAX specifies a preferred policy for using public or system IDs to resolve resources. However, SAX specifies how to interpret any InputSource returned by this method, and that if none is returned, then the system ID will be dereferenced as a URL. If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to the application.
| |
| resolveEntity | back to summary |
|---|---|
| public InputSource resolveEntity(String name, String publicId, String base, String systemId) throws SAXException, IOException Implements org. Doc from org. Allows applications to map references to external entities into input
sources, or tell the parser it should use conventional URI resolution.
This method is only called for external entities which have been
properly declared.
This method provides more flexibility than the Parsers configured to use this resolver method will call it
to determine the input source to use for any external entity
being included because of a reference in the XML text.
That excludes the document entity, and any external entity returned
by Note that the entity naming scheme used here is the same one
used in the
| |