Interface IEntityResolver2
Extended interface for mapping external entity references to input
sources, or providing a missing external subset. The
Entity
Inherited Members
Namespace: Sax.Ext
Assembly: Lucene.Net.Benchmark.dll
Syntax
public interface IEntityResolver2 : IEntityResolver
Remarks
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.
If a SAX application requires the customized handling which this
interface defines for external entities, it must ensure that it uses
an XMLReader with the
http://xml.org/sax/features/use-entity-resolver2 feature flag
set to true (which is its default value when the feature is
recognized). If that flag is unrecognized, or its value is false,
or the resolver does not implement this interface, then only the
IEntity
That supports three categories of application that modify entity
resolution. Old Style applications won't know about this interface;
they will provide an IEntity
Methods
| Improve this Doc View SourceGetExternalSubset(String, String)
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 Start
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
Resolve
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 attibutes 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.
Declaration
InputSource GetExternalSubset(string name, string baseURI)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Identifies the document root element. This name comes from a DOCTYPE declaration (where available) or from the actual root element. |
System. |
baseURI | 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. |
Returns
Type | Description |
---|---|
Input |
An Input |
Exceptions
Type | Condition |
---|---|
SAXException | Any SAX exception, possibly wrapping another exception. |
ResolveEntity(String, String, String, String)
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 IEntity
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 Get
Note that the entity naming scheme used here is the same one
used in the ILexical
Declaration
InputSource ResolveEntity(string name, string publicId, string baseURI, string systemId)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | 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 |
System. |
publicId | The public identifier of the external entity being referenced (normalized as required by the XML specification), or null if none was supplied. |
System. |
baseURI | The URI with respect to which relative systemIDs
are interpreted. This is always an absolute URI, unless it is
null (likely because the IXMLReader was given an Input |
System. |
systemId | 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. |
Returns
Type | Description |
---|---|
Input |
An Input |
Exceptions
Type | Condition |
---|---|
SAXException | Any SAX exception, possibly wrapping another exception. |