package org.sfc.xml.sax;
import java.io.IOException;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.EntityResolver2;
import org.xml.sax.ext.LexicalHandler;
/**
* This class has no semantic function, it just implements all the usefull
* sax interfaces.
*
* @author Thomas Weise
*/
public class SAXImplementor implements EntityResolver,
DTDHandler,
ContentHandler,
ErrorHandler,
LexicalHandler,
EntityResolver2,
DeclHandler
{
/**
* The property for lexical handlers.
*/
public static final String PROPERTY_LEXICAL_HANDLER =
"http://xml.org/sax/properties/lexical-handler";
/**
* The property for decl handlers.
*/
public static final String PROPERTY_DECL_HANDLER =
"http://xml.org/sax/properties/declaration-handler";
/**
* <code>EntityResolver2</code>s are recognized.
*/
public static final String FEATURE_ENTITY_RESOLVER_2 =
"http://xml.org/sax/features/use-entity-resolver2";
/**
* Create a new <code>SAXImplementor</code>. This constructor ensures
* that <code>SAXImplementor</code>s will only be created from subclasses
* and not by hand.
*/
protected SAXImplementor()
{
super();
}
///
/// EntityResolver
///
/**
* Allow the application to resolve external entities.
*
* <p>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).</p>
*
* <p>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. </p>
*
* <p>If the system identifier is a URL, the SAX parser must
* resolve it fully before reporting it to the application.</p>
*
* @param p_public_id The public identifier of the external entity
* being referenced, or null if none was supplied.
* @param p_system_id The system identifier of the external entity
* being referenced.
* @return An InputSource object describing the new input source,
* or null to request that the parser open a regular
* URI connection to the system identifier.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception java.io.IOException A Java-specific IO exception,
* possibly the result of creating a new InputStream
* or Reader for the InputSource.
* @see org.xml.sax.InputSource
*/
public InputSource resolveEntity (final String p_public_id,
final String p_system_id)
throws SAXException, IOException
{
return null;
}
///
/// DTDHandler
///
/**
* Receive notification of a notation declaration event.
*
* <p>It is up to the application to record the notation for later
* reference, if necessary;
* notations may appear as attribute values and in unparsed entity
* declarations, and are sometime used with processing instruction
* target names.</p>
*
* <p>At least one of publicId and systemId must be non-null.
* If a system identifier is present, and it is a URL, the SAX
* parser must resolve it fully before passing it to the
* application through this event.</p>
*
* <p>There is no guarantee that the notation declaration will be
* reported before any unparsed entities that use it.</p>
*
* @param p_name The notation name.
* @param p_public_id The notation's public identifier, or null if
* none was given.
* @param p_system_id The notation's system identifier, or null if
* none was given.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #unparsedEntityDecl
* @see org.xml.sax.Attributes
*/
public void notationDecl ( final String p_name,
final String p_public_id,
final String p_system_id)
throws SAXException
{
//does nothing
}
/**
* Receive notification of an unparsed entity declaration event.
*
* <p>Note that the notation name corresponds to a notation
* reported by the {@link #notationDecl notationDecl} event.
* It is up to the application to record the entity for later
* reference, if necessary;
* unparsed entities may appear as attribute values.
* </p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @param p_name The unparsed entity's name.
* @param p_public_id The entity's public identifier, or null if none
* was given.
* @param p_system_id The entity's system identifier.
* @param p_notation_name The name of the associated notation.
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #notationDecl
* @see org.xml.sax.Attributes
*/
public void unparsedEntityDecl ( final String p_name,
final String p_public_id,
final String p_system_id,
final String p_notation_name)
throws SAXException
{
//does nothing
}
///
/// ContentHandler
///
/**
* Receive an object for locating the origin of SAX document events.
*
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the ContentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.</p>
*
* <p>Note that the locator will return correct information only
* during the invocation SAX event callbacks after
* {@link #startDocument startDocument} returns and before
* {@link #endDocument endDocument} is called. The
* application should not attempt to use it at any other time.</p>
*
* @param p_locator an object that can return the location of
* any SAX document event
* @see org.xml.sax.Locator
*/
public void setDocumentLocator (final Locator p_locator)
{
//does nothing
}
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other event callbacks (except for {@link #setDocumentLocator
* setDocumentLocator}).</p>
*
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
* @see #endDocument
*/
public void startDocument () throws SAXException
{
//does nothing
}
/**
* Receive notification of the end of a document.
*
* <p><strong>There is an apparent contradiction between the
* documentation for this method and the documentation for {@link
* org.xml.sax.ErrorHandler#fatalError}. Until this ambiguity is
* resolved in a future major release, clients should make no
* assumptions about whether endDocument() will or will not be
* invoked when the parser has reported a fatalError() or thrown
* an exception.</strong></p>
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
* @see #startDocument
*/
public void endDocument() throws SAXException
{
//does nothing
}
/**
* Begin the scope of a prefix-URI Namespace mapping.
*
* <p>The information from this event is not necessary for
* normal Namespace processing: the SAX XML reader will
* automatically replace prefixes for element and attribute
* names when the <code>http://xml.org/sax/features/namespaces</code>
* feature is <var>true</var> (the default).</p>
*
* <p>There are cases, however, when applications need to
* use prefixes in character data or in attribute values,
* where they cannot safely be expanded automatically; the
* start/endPrefixMapping event supplies the information
* to the application to expand prefixes in those contexts
* itself, if necessary.</p>
*
* <p>Note that start/endPrefixMapping events are not
* guaranteed to be properly nested relative to each other:
* all startPrefixMapping events will occur immediately before the
* corresponding {@link #startElement startElement} event,
* and all {@link #endPrefixMapping endPrefixMapping}
* events will occur immediately after the corresponding
* {@link #endElement endElement} event,
* but their order is not otherwise
* guaranteed.</p>
*
* <p>There should never be start/endPrefixMapping events for the
* "xml" prefix, since it is predeclared and immutable.</p>
*
* @param p_prefix the Namespace prefix being declared.
* An empty string is used for the default element namespace,
* which has no prefix.
* @param p_uri the Namespace URI the prefix is mapped to
* @throws org.xml.sax.SAXException the client may throw
* an exception during processing
* @see #endPrefixMapping
* @see #startElement
*/
public void startPrefixMapping (final String p_prefix,
final String p_uri) throws SAXException
{
//does nothing
}
/**
* End the scope of a prefix-URI mapping.
*
* <p>See {@link #startPrefixMapping startPrefixMapping} for
* details. These events will always occur immediately after the
* corresponding {@link #endElement endElement} event, but the order of
* {@link #endPrefixMapping endPrefixMapping} events is not otherwise
* guaranteed.</p>
*
* @param p_prefix the prefix that was being mapped.
* This is the empty string when a default mapping scope ends.
* @throws org.xml.sax.SAXException the client may throw
* an exception during processing
* @see #startPrefixMapping
* @see #endElement
*/
public void endPrefixMapping (final String p_prefix) throws SAXException
{
//does nothing
}
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* {@link #endElement endElement} event for every startElement event
* (even when the element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement
* event.</p>
*
* <p>This event allows up to three name components for each
* element:</p>
*
* <ol>
* <li>the Namespace URI;</li>
* <li>the local name; and</li>
* <li>the qualified (prefixed) name.</li>
* </ol>
*
* <p>Any or all of these may be provided, depending on the
* values of the <var>http://xml.org/sax/features/namespaces</var>
* and the <var>http://xml.org/sax/features/namespace-prefixes</var>
* properties:</p>
*
* <ul>
* <li>the Namespace URI and local name are required when
* the namespaces property is <var>true</var> (the default), and are
* optional when the namespaces property is <var>false</var> (if one is
* specified, both must be);</li>
* <li>the qualified name is required when the namespace-prefixes property
* is <var>true</var>, and is optional when the namespace-prefixes property
* is <var>false</var> (the default).</li>
* </ul>
*
* <p>Note that the attribute list provided will contain only
* attributes with explicit values (specified or defaulted):
* #IMPLIED attributes will be omitted. The attribute list
* will contain attributes used for Namespace declarations
* (xmlns* attributes) only if the
* <code>http://xml.org/sax/features/namespace-prefixes</code>
* property is true (it is false by default, and support for a
* true value is optional).</p>
*
* <p>Like {@link #characters characters()}, attribute values may have
* characters that need more than one <code>char</code> value. </p>
*
* @param p_uri the Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed
* @param p_local_name the local name (without prefix), or the
* empty string if Namespace processing is not being
* performed
* @param p_q_name the qualified name (with prefix), or the
* empty string if qualified names are not available
* @param p_atts the attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object. The value of this object after
* startElement returns is undefined
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
* @see #endElement
* @see org.xml.sax.Attributes
*/
public void startElement (final String p_uri,
final String p_local_name,
final String p_q_name,
final Attributes p_atts)
throws SAXException
{
//does nothing
}
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* {@link #startElement startElement} event for every endElement
* event (even when the element is empty).</p>
*
* <p>For information on the names, see startElement.</p>
*
* @param p_uri the Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
* processing is not being performed
* @param p_local_name the local name (without prefix), or the
* empty string if Namespace processing is not being
* performed
* @param p_q_name the qualified XML name (with prefix), or the
* empty string if qualified names are not available
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
*/
public void endElement (final String p_uri,
final String p_local_name,
final String p_q_name)
throws SAXException
{
//does nothing
}
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Individual characters may consist of more than one Java
* <code>char</code> value. There are two important cases where this
* happens, because characters can't be represented in just sixteen bits.
* In one case, characters are represented in a <em>Surrogate Pair</em>,
* using two special Unicode values. Such characters are in the so-called
* "Astral Planes", with a code point above U+FFFF. A second case involves
* composite characters, such as a base character combining with one or
* more accent characters. </p>
*
* <p> Your code should not assume that algorithms using
* <code>char</code>-at-a-time idioms will be working in character
* units; in some cases they will split characters. This is relevant
* wherever XML permits arbitrary characters, such as attribute values,
* processing instruction data, and comments as well as in data reported
* from this method. It's also generally relevant whenever Java code
* manipulates internationalized text; the issue isn't unique to XML.</p>
*
* <p>Note that some parsers will report whitespace in element
* content using the {@link #ignorableWhitespace ignorableWhitespace}
* method rather than this one (validating parsers <em>must</em>
* do so).</p>
*
* @param p_ch the characters from the XML document
* @param p_start the start position in the array
* @param p_length the number of characters to read from the array
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
public void characters (final char p_ch[],
final int p_start,
final int p_length) throws SAXException
{
//does nothing
}
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of whitespace in element content (see the W3C XML 1.0
* recommendation, section 2.10): non-validating parsers may also
* use this method if they are capable of parsing and using
* content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param p_ch the characters from the XML document
* @param p_start the start position in the array
* @param p_length the number of characters to read from the array
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
* @see #characters
*/
public void ignorableWhitespace (final char p_ch[],
final int p_start,
final int p_length) throws SAXException
{
//does nothing
}
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser must never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* <p>Like {@link #characters characters()}, processing instruction
* data may have characters that need more than one <code>char</code>
* value. </p>
*
* @param p_target the processing instruction target
* @param p_data the processing instruction data, or null if
* none was supplied. The data does not include any
* whitespace separating it from the target
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
*/
public void processingInstruction (final String p_target,
final String p_data)
throws SAXException
{
//does nothing
}
/**
* Receive notification of a skipped entity.
* This is not called for entity references within markup constructs
* such as element start tags or markup declarations. (The XML
* recommendation requires reporting skipped external entities.
* SAX also reports internal entity expansion/non-expansion, except
* within markup constructs.)
*
* <p>The Parser will invoke this method each time the entity is
* skipped. Non-validating processors may skip entities if they
* have not seen the declarations (because, for example, the
* entity was declared in an external DTD subset). All processors
* may skip external entities, depending on the values of the
* <code>http://xml.org/sax/features/external-general-entities</code>
* and the
* <code>http://xml.org/sax/features/external-parameter-entities</code>
* properties.</p>
*
* @param p_name the name of the skipped entity. If it is a
* parameter entity, the name will begin with '%', and if
* it is the external DTD subset, it will be the string
* "[dtd]"
* @throws org.xml.sax.SAXException any SAX exception, possibly
* wrapping another exception
*/
public void skippedEntity (final String p_name) throws SAXException
{
//does nothing
}
///
/// ErrorHandler
///
/**
* Receive notification of a warning.
*
* <p>SAX parsers will use this method to report conditions that
* are not errors or fatal errors as defined by the XML
* recommendation. The default behaviour is to take no
* action.</p>
*
* <p>The SAX parser must continue to provide normal parsing events
* after invoking this method: it should still be possible for the
* application to process the document through to the end.</p>
*
* <p>Filters may use this method to report other, non-XML warnings
* as well.</p>
*
* @param p_exception The warning information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public void warning (final SAXParseException p_exception)
throws SAXException
{
//does nothing
}
/**
* Receive notification of a recoverable error.
*
* <p>This corresponds to the definition of "error" in section 1.2
* of the W3C XML 1.0 Recommendation. For example, a validating
* parser would use this callback to report the violation of a
* validity constraint. The default behaviour is to take no
* action.</p>
*
* <p>The SAX parser must continue to provide normal parsing
* events after invoking this method: it should still be possible
* for the application to process the document through to the end.
* If the application cannot do so, then the parser should report
* a fatal error even if the XML recommendation does not require
* it to do so.</p>
*
* <p>Filters may use this method to report other, non-XML errors
* as well.</p>
*
* @param p_exception The error information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public void error (final SAXParseException p_exception)
throws SAXException
{
//does nothing
}
/**
* Receive notification of a non-recoverable error.
*
* <p><strong>There is an apparent contradiction between the
* documentation for this method and the documentation for {@link
* org.xml.sax.ContentHandler#endDocument}. Until this ambiguity
* is resolved in a future major release, clients should make no
* assumptions about whether endDocument() will or will not be
* invoked when the parser has reported a fatalError() or thrown
* an exception.</strong></p>
*
* <p>This corresponds to the definition of "fatal error" in
* section 1.2 of the W3C XML 1.0 Recommendation. For example, a
* parser would use this callback to report the violation of a
* well-formedness constraint.</p>
*
* <p>The application must assume that the document is unusable
* after the parser has invoked this method, and should continue
* (if at all) only for the sake of collecting additional error
* messages: in fact, SAX parsers are free to stop reporting any
* other events once this method has been invoked.</p>
*
* @param p_exception The error information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.SAXParseException
*/
public void fatalError (final SAXParseException p_exception)
throws SAXException
{
//does nothing
}
///
/// LexicalHandler
///
/**
* Report the start of DTD declarations, if any.
*
* <p>This method is intended to report the beginning of the
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
* this method will not be invoked.</p>
*
* <p>All declarations reported through
* {@link org.xml.sax.DTDHandler DTDHandler} or
* {@link org.xml.sax.ext.DeclHandler DeclHandler} events must appear
* between the startDTD and {@link #endDTD endDTD} events.
* Declarations are assumed to belong to the internal DTD subset
* unless they appear between {@link #startEntity startEntity}
* and {@link #endEntity endEntity} events. Comments and
* processing instructions from the DTD should also be reported
* between the startDTD and endDTD events, in their original
* order of (logical) occurrence; they are not required to
* appear in their correct locations relative to DTDHandler
* or DeclHandler events, however.</p>
*
* <p>Note that the start/endDTD events will appear within
* the start/endDocument events from ContentHandler and
* before the first
* {@link org.xml.sax.ContentHandler#startElement startElement}
* event.</p>
*
* @param p_name The document type name.
* @param p_public_id The declared public identifier for the
* external DTD subset, or null if none was declared.
* @param p_system_id The declared system identifier for the
* external DTD subset, or null if none was declared.
* (Note that this is not resolved against the document
* base URI.)
* @exception SAXException The application may raise an
* exception.
* @see #endDTD
* @see #startEntity
*/
public void startDTD (final String p_name,
final String p_public_id,
final String p_system_id) throws SAXException
{
//does nothing
}
/**
* Report the end of DTD declarations.
*
* <p>This method is intended to report the end of the
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
* this method will not be invoked.</p>
*
* @exception SAXException The application may raise an exception.
* @see #startDTD
*/
public void endDTD () throws SAXException
{
//does nothing
}
/**
* Report the beginning of some internal and external XML entities.
*
* <p>The reporting of parameter entities (including
* the external DTD subset) is optional, and SAX2 drivers that
* report LexicalHandler events may not implement it; you can use the
* <code
* >http://xml.org/sax/features/lexical-handler/parameter-entities</code>
* feature to query or control the reporting of parameter entities.</p>
*
* <p>General entities are reported with their regular names,
* parameter entities have '%' prepended to their names, and
* the external DTD subset has the pseudo-entity name "[dtd]".</p>
*
* <p>When a SAX2 driver is providing these events, all other
* events must be properly nested within start/end entity
* events. There is no additional requirement that events from
* {@link org.xml.sax.ext.DeclHandler DeclHandler} or
* {@link org.xml.sax.DTDHandler DTDHandler} be properly ordered.</p>
*
* <p>Note that skipped entities will be reported through the
* {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
* event, which is part of the ContentHandler interface.</p>
*
* <p>Because of the streaming event model that SAX uses, some
* entity boundaries cannot be reported under any
* circumstances:</p>
*
* <ul>
* <li>general entities within attribute values</li>
* <li>parameter entities within declarations</li>
* </ul>
*
* <p>These will be silently expanded, with no indication of where
* the original entity boundaries were.</p>
*
* <p>Note also that the boundaries of character references (which
* are not really entities anyway) are not reported.</p>
*
* <p>All start/endEntity events must be properly nested.
*
* @param p_name The name of the entity. If it is a parameter
* entity, the name will begin with '%', and if it is the
* external DTD subset, it will be "[dtd]".
* @exception SAXException The application may raise an exception.
* @see #endEntity
* @see org.xml.sax.ext.DeclHandler#internalEntityDecl
* @see org.xml.sax.ext.DeclHandler#externalEntityDecl
*/
public void startEntity (final String p_name) throws SAXException
{
//does nothing
}
/**
* Report the end of an entity.
*
* @param p_name The name of the entity that is ending.
* @exception SAXException The application may raise an exception.
* @see #startEntity
*/
public void endEntity (final String p_name) throws SAXException
{
//does nothing
}
/**
* Report the start of a CDATA section.
*
* <p>The contents of the CDATA section will be reported through
* the regular {@link org.xml.sax.ContentHandler#characters
* characters} event; this event is intended only to report
* the boundary.</p>
*
* @exception SAXException The application may raise an exception.
* @see #endCDATA
*/
public void startCDATA () throws SAXException
{
//does nothing
}
/**
* Report the end of a CDATA section.
*
* @exception SAXException The application may raise an exception.
* @see #startCDATA
*/
public void endCDATA () throws SAXException
{
//does nothing
}
/**
* Report an XML comment anywhere in the document.
*
* <p>This callback will be used for comments inside or outside the
* document element, including comments in the external DTD
* subset (if read). Comments in the DTD must be properly
* nested inside start/endDTD and start/endEntity events (if
* used).</p>
*
* @param p_ch An array holding the characters in the comment.
* @param p_start The starting position in the array.
* @param p_length The number of characters to use from the array.
* @exception SAXException The application may raise an exception.
*/
public void comment (final char p_ch[],
final int p_start,
final int p_length) throws SAXException
{
//does nothing
}
///
/// EntityResolver2
///
/**
* 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 {@link LexicalHandler#startDTD startDTD()} method as if
* the document text had originally included the external subset;
* this callback is made before any internal subset data or errors
* are reported.</p>
*
* <p>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:</p>
*
* <pre>
* ... 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", ...);
* </pre>
*
* <p>Note that the InputSource gets no further resolution.
* Implementations of this method may wish to invoke
* <code>resolveEntity</code> to gain benefits such as use
* of local caches of DTD entities. Also, this method will never be
* used by a (non-validating) processor that is not including external
* parameter entities. </p>
*
* <p>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.</p>
*
* <p><strong>Warning:</strong> 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.
* </p>
*
* @param p_name Identifies the document root element. This name comes
* from a DOCTYPE declaration (where available) or from the actual
* root element.
* @param p_base_uri 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.
*
* @return An InputSource object describing the new external subset
* to be used by the parser, or null to indicate that no external
* subset is provided.
*
* @exception SAXException Any SAX exception, possibly wrapping
* another exception.
* @exception IOException Probably indicating a failure to create
* a new InputStream or Reader, or an illegal URL.
*/
public InputSource getExternalSubset (final String p_name,
final String p_base_uri)
throws SAXException, IOException
{
return null;
}
/**
* 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 {@link EntityResolver}
* interface, supporting implementations of more complex catalogue
* schemes such as the one defined by the <a href=
"http://www.oasis-open.org/committees/entity/spec-2001-08-06.html"
>OASIS XML Catalogs</a> specification.</p>
*
* <p>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 {@link #getExternalSubset getExternalSubset()}.
* When a (non-validating) processor is configured not to include
* a class of entities (parameter or general) through use of feature
* flags, this method is not invoked for such entities. </p>
*
* <p>Note that the entity naming scheme used here is the same one
* used in the {@link LexicalHandler}, or in the {@link
org.xml.sax.ContentHandler#skippedEntity
ContentHandler.skippedEntity()}
* method. </p>
*
* @param p_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
* parser.
* @param p_public_id The public identifier of the external entity being
* referenced (normalized as required by the XML specification), or
* null if none was supplied.
* @param p_base_uri 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.
* @param p_system_id 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.
*
* @return An InputSource object describing the new input source to
* be used by the parser. Returning null directs the parser to
* resolve the system ID against the base URI and open a connection
* to resulting URI.
*
* @exception SAXException Any SAX exception, possibly wrapping
* another exception.
* @exception IOException Probably indicating a failure to create
* a new InputStream or Reader, or an illegal URL.
*/
public InputSource resolveEntity (final String p_name,
final String p_public_id,
final String p_base_uri,
final String p_system_id)
throws SAXException, IOException
{
return null;
}
///
/// DeclHandler
///
/**
* Report an element type declaration.
*
* <p>The content model will consist of the string "EMPTY", the
* string "ANY", or a parenthesised group, optionally followed
* by an occurrence indicator. The model will be normalized so
* that all parameter entities are fully resolved and all whitespace
* is removed,and will include the enclosing parentheses. Other
* normalization (such as removing redundant parentheses or
* simplifying occurrence indicators) is at the discretion of the
* parser.</p>
*
* @param p_name The element type name.
* @param p_model The content model as a normalized string.
* @exception SAXException The application may raise an exception.
*/
public void elementDecl (final String p_name,
final String p_model)
throws SAXException
{
//does nothing
}
/**
* Report an attribute type declaration.
*
* <p>Only the effective (first) declaration for an attribute will
* be reported. The type will be one of the strings "CDATA",
* "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
* "ENTITIES", a parenthesized token group with
* the separator "|" and all whitespace removed, or the word
* "NOTATION" followed by a space followed by a parenthesized
* token group with all whitespace removed.</p>
*
* <p>The value will be the value as reported to applications,
* appropriately normalized and with entity and character
* references expanded. </p>
*
* @param p_e_name The name of the associated element.
* @param p_a_name The name of the attribute.
* @param p_type A string representing the attribute type.
* @param p_mode A string representing the attribute defaulting mode
* ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
* none of these applies.
* @param p_value A string representing the attribute's default value,
* or null if there is none.
* @exception SAXException The application may raise an exception.
*/
public void attributeDecl (final String p_e_name,
final String p_a_name,
final String p_type,
final String p_mode,
final String p_value) throws SAXException
{
//does nothing
}
/**
* Report an internal entity declaration.
*
* <p>Only the effective (first) declaration for each entity
* will be reported. All parameter entities in the value
* will be expanded, but general entities will not.</p>
*
* @param p_name The name of the entity. If it is a parameter
* entity, the name will begin with '%'.
* @param p_value The replacement text of the entity.
* @exception SAXException The application may raise an exception.
* @see #externalEntityDecl
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
*/
public void internalEntityDecl (final String p_name,
final String p_value) throws SAXException
{
//does nothing
}
/**
* Report a parsed external entity declaration.
*
* <p>Only the effective (first) declaration for each entity
* will be reported.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @param p_name The name of the entity. If it is a parameter
* entity, the name will begin with '%'.
* @param p_public_id The entity's public identifier, or null if none
* was given.
* @param p_system_id The entity's system identifier.
* @exception SAXException The application may raise an exception.
* @see #internalEntityDecl
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
*/
public void externalEntityDecl (final String p_name,
final String p_public_id,
final String p_system_id)
throws SAXException
{
//does nothing
}
///
/// Locator 2
///
/**
* Returns the version of XML used for the entity. This will
* normally be the identifier from the current entity's
* <em><?xml version='...' ...?></em> declaration,
* or be defaulted by the parser.
*
* @return Identifier for the XML version being used to interpret
* the entity's text, or null if that information is not yet
* available in the current parsing state.
*/
public String getXMLVersion ()
{
return null;
}
/**
* Returns the name of the character encoding for the entity.
* If the encoding was declared externally (for example, in a MIME
* Content-Type header), that will be the name returned. Else if there
* was an <em><?xml ...encoding='...'?></em> declaration at
* the start of the document, that encoding name will be returned.
* Otherwise the encoding will been inferred (normally to be UTF-8, or
* some UTF-16 variant), and that inferred name will be returned.
*
* <p>When an {@link org.xml.sax.InputSource InputSource} is used
* to provide an entity's character stream, this method returns the
* encoding provided in that input stream.
*
* <p> Note that some recent W3C specifications require that text
* in some encodings be normalized, using Unicode Normalization
* Form C, before processing. Such normalization must be performed
* by applications, and would normally be triggered based on the
* value returned by this method.
*
* <p> Encoding names may be those used by the underlying JVM,
* and comparisons should be case-insensitive.
*
* @return Name of the character encoding being used to interpret
* * the entity's text, or null if this was not provided for a *
* character stream passed through an InputSource or is otherwise
* not yet available in the current parsing state.
*/
public String getEncoding ()
{
return null;
}
/**
* Installs this xml implementor to an xml reader.
* This method will set all the xml reader's supported handlers to this
* object so any sax event produced by the reader will be tunnelled to this
* object.
*
* @param p_reader The reader to install to.
*/
public void install_to (final XMLReader p_reader)
{
p_reader.setContentHandler(this);
p_reader.setDTDHandler(this);
p_reader.setEntityResolver(this);
p_reader.setErrorHandler(this);
try
{
p_reader.setProperty(PROPERTY_LEXICAL_HANDLER, this);
}
catch(Throwable l_t)
{
//
}
try
{
p_reader.setProperty(PROPERTY_DECL_HANDLER, this);
}
catch(Throwable l_t)
{
//
}
try
{
p_reader.setFeature(FEATURE_ENTITY_RESOLVER_2, true);
}
catch(Throwable l_t)
{
//
}
}
/**
* Uninstalls this xml implementor from an xml reader.
* This method will set all the xml reader's supported handlers that point
* currently to this object to null, so it is ensured that no more events
* will be received from the reader.
*
* @param p_reader The reader to install to.
*/
public void uninstall_from (final XMLReader p_reader)
{
if(p_reader.getContentHandler() == this)
{
p_reader.setContentHandler(null);
}
if(p_reader.getDTDHandler() == this)
{
p_reader.setDTDHandler(null);
}
if(p_reader.getEntityResolver() == this)
{
p_reader.setEntityResolver(null);
}
if(p_reader.getErrorHandler() == this)
{
p_reader.setErrorHandler(null);
}
try
{
if(p_reader.getProperty(PROPERTY_LEXICAL_HANDLER) == this)
{
p_reader.setProperty(PROPERTY_LEXICAL_HANDLER, null);
}
}
catch(Throwable l_t)
{
//
}
try
{
if(p_reader.getProperty(PROPERTY_DECL_HANDLER) == this)
{
p_reader.setProperty(PROPERTY_DECL_HANDLER, null);
}
}
catch(Throwable l_t)
{
//
}
}
}