Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class DefaultHandler2

    This class extends the SAX2 base handler class to support the SAX2 ILexicalHandler, IDeclHandler, and IEntityResolver2 extensions. Except for overriding the original SAX1 ResolveEntity(string, string) method the added handler methods just return. Subclassers may override everything on a method-by-method basis.

    Inheritance
    object
    DefaultHandler
    DefaultHandler2
    Implements
    IDTDHandler
    IContentHandler
    IErrorHandler
    ILexicalHandler
    IDeclHandler
    IEntityResolver2
    IEntityResolver
    Inherited Members
    DefaultHandler.NotationDecl(string, string, string)
    DefaultHandler.UnparsedEntityDecl(string, string, string, string)
    DefaultHandler.SetDocumentLocator(ILocator)
    DefaultHandler.StartDocument()
    DefaultHandler.EndDocument()
    DefaultHandler.StartPrefixMapping(string, string)
    DefaultHandler.EndPrefixMapping(string)
    DefaultHandler.StartElement(string, string, string, IAttributes)
    DefaultHandler.EndElement(string, string, string)
    DefaultHandler.Characters(char[], int, int)
    DefaultHandler.IgnorableWhitespace(char[], int, int)
    DefaultHandler.ProcessingInstruction(string, string)
    DefaultHandler.SkippedEntity(string)
    DefaultHandler.Warning(SAXParseException)
    DefaultHandler.Error(SAXParseException)
    DefaultHandler.FatalError(SAXParseException)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Sax.Ext
    Assembly: Lucene.Net.Benchmark.dll
    Syntax
    public class DefaultHandler2 : DefaultHandler, IDTDHandler, IContentHandler, IErrorHandler, ILexicalHandler, IDeclHandler, IEntityResolver2, IEntityResolver
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.

    Constructors

    DefaultHandler2()

    Constructs a handler which ignores all parsing events.

    Declaration
    public DefaultHandler2()
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.

    Methods

    AttributeDecl(string, string, string, string, string)

    Report an attribute type declaration.

    Declaration
    public virtual void AttributeDecl(string eName, string aName, string type, string mode, string value)
    Parameters
    Type Name Description
    string eName

    The name of the associated element.

    string aName

    The name of the attribute.

    string type

    A string representing the attribute type.

    string mode

    A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.

    string value

    A string representing the attribute's default value, or null if there is none.

    Remarks

    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.

    The value will be the value as reported to applications, appropriately normalized and with entity and character references expanded.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    Comment(char[], int, int)

    Report an XML comment anywhere in the document.

    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).
    Declaration
    public virtual void Comment(char[] ch, int start, int length)
    Parameters
    Type Name Description
    char[] ch

    An array holding the characters in the comment.

    int start

    The starting position in the array.

    int length

    The number of characters to use from the array.

    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    ElementDecl(string, string)

    Report an element type declaration.

    Declaration
    public virtual void ElementDecl(string name, string model)
    Parameters
    Type Name Description
    string name

    The element type name.

    string model

    The content model as a normalized string.

    Remarks

    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.

    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    EndCDATA()

    Report the end of a CDATA section.

    Declaration
    public virtual void EndCDATA()
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    StartCDATA()

    EndDTD()

    Report the end of DTD declarations.

    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.
    Declaration
    public virtual void EndDTD()
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    StartDTD(string, string, string)

    EndEntity(string)

    Report the end of an entity.

    Declaration
    public virtual void EndEntity(string name)
    Parameters
    Type Name Description
    string name

    The name of the entity that is ending.

    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    StartEntity(string)

    ExternalEntityDecl(string, string, string)

    Report a parsed external entity declaration.

    Declaration
    public virtual void ExternalEntityDecl(string name, string publicId, string systemId)
    Parameters
    Type Name Description
    string name

    The name of the entity. If it is a parameter entity, the name will begin with '%'.

    string publicId

    The entity's public identifier, or null if none was given.

    string systemId

    The entity's system identifier.

    Remarks

    Only the effective (first) declaration for each entity will be reported.

    If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    InternalEntityDecl(string, string)
    UnparsedEntityDecl(string, string, string, string)

    GetExternalSubset(string, string)

    Tells the parser that if no external subset has been declared in the document text, none should be used.

    Declaration
    public virtual InputSource GetExternalSubset(string name, string baseURI)
    Parameters
    Type Name Description
    string name
    string baseURI
    Returns
    Type Description
    InputSource
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.

    InternalEntityDecl(string, string)

    Report an internal entity declaration.

    Declaration
    public virtual void InternalEntityDecl(string name, string value)
    Parameters
    Type Name Description
    string name

    The name of the entity. If it is a parameter entity, the name will begin with '%'.

    string value

    The replacement text of the entity.

    Remarks

    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.

    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    ExternalEntityDecl(string, string, string)
    UnparsedEntityDecl(string, string, string, string)

    ResolveEntity(string, string)

    Invokes ResolveEntity(string, string, string, string) with null entity name and base URI. You only need to override that method to use this class.

    Declaration
    public override InputSource ResolveEntity(string publicId, string systemId)
    Parameters
    Type Name Description
    string publicId
    string systemId
    Returns
    Type Description
    InputSource
    Overrides
    DefaultHandler.ResolveEntity(string, string)
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.

    ResolveEntity(string, string, string, string)

    Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI. Note that because the older ResolveEntity(string, string), method is overridden to call this one, this method may sometimes be invoked with null name and baseURI, and with the systemId already absolutized.

    Declaration
    public virtual InputSource ResolveEntity(string name, string publicId, string baseURI, string systemId)
    Parameters
    Type Name Description
    string name
    string publicId
    string baseURI
    string systemId
    Returns
    Type Description
    InputSource
    Remarks

    This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

    Note: this class might yet learn that the SetDocumentLocator(ILocator) call might be passed a Locator2 object, and that the ContentHandler.startElement() call might be passed a Attributes2 object.

    StartCDATA()

    Report the start of a CDATA section.

    Declaration
    public virtual void StartCDATA()
    Remarks

    The contents of the CDATA section will be reported through the regular Characters(char[], int, int) event; this event is intended only to report the boundary.

    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    EndEntity(string)

    StartDTD(string, string, string)

    Report the start of DTD declarations, if any.

    Declaration
    public virtual void StartDTD(string name, string publicId, string systemId)
    Parameters
    Type Name Description
    string name

    The document type name.

    string publicId

    The declared public identifier for the external DTD subset, or null if none was declared.

    string systemId

    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.)

    Remarks

    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.

    All declarations reported through IDTDHandler or IDeclHandler events must appear between the startDTD and EndDTD() events. Declarations are assumed to belong to the internal DTD subset unless they appear between StartEntity(string) and EndEntity(string) events. Comments and processing instructions from the DTD should also be reported between the StartDTD(string, string, string) and EndDTD() events, in their original order of(logical) occurrence; they are not required to appear in their correct locations relative to IDTDHandler or IDeclHandler events, however.

    Note that the start / endDTD events will appear within the start / endDocument events from IContentHandler and before the first StartElement(string, string, string, IAttributes) event.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    StartEntity(string)

    Report the beginning of some internal and external XML entities.

    Declaration
    public virtual void StartEntity(string name)
    Parameters
    Type Name Description
    string 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]".

    Remarks

    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 http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control the reporting of parameter entities.

    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]".

    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 IDeclHandler or IDTDHandler be properly ordered.

    Note that skipped entities will be reported through the SkippedEntity(string) event, which is part of the ContentHandler interface.

    Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:
    • general entities within attribute values
    • parameter entities within declarations

    These will be silently expanded, with no indication of where the original entity boundaries were.

    Note also that the boundaries of character references (which are not really entities anyway) are not reported.

    All start/endEntity events must be properly nested.
    Exceptions
    Type Condition
    SAXException

    The application may raise an exception.

    See Also
    EndEntity(string)
    InternalEntityDecl(string, string)
    ExternalEntityDecl(string, string, string)

    Implements

    IDTDHandler
    IContentHandler
    IErrorHandler
    ILexicalHandler
    IDeclHandler
    IEntityResolver2
    IEntityResolver
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.