Package org.dom4j.io

Class SAXContentHandler

    • Constructor Detail

      • SAXContentHandler

        public SAXContentHandler()
      • SAXContentHandler

        public SAXContentHandler​(DocumentFactory documentFactory)
      • SAXContentHandler

        public SAXContentHandler​(DocumentFactory documentFactory,
                                 ElementHandler elementHandler,
                                 org.dom4j.io.ElementStack elementStack)
    • Method Detail

      • getDocument

        public Document getDocument()
        DOCUMENT ME!
        Returns:
        the document that has been or is being built
      • elementDecl

        public void elementDecl​(String name,
                                String model)
                         throws SAXException
        Report an element type declaration.

        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.

        Specified by:
        elementDecl in interface DeclHandler
        Parameters:
        name - The element type name.
        model - The content model as a normalized string.
        Throws:
        SAXException - The application may raise an exception.
      • attributeDecl

        public void attributeDecl​(String eName,
                                  String aName,
                                  String type,
                                  String valueDefault,
                                  String val)
                           throws SAXException
        Report an attribute type declaration.

        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.

        Any parameter entities in the attribute value will be expanded, but general entities will not.

        Specified by:
        attributeDecl in interface DeclHandler
        Parameters:
        eName - The name of the associated element.
        aName - The name of the attribute.
        type - A string representing the attribute type.
        valueDefault - A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
        val - A string representing the attribute's default value, or null if there is none.
        Throws:
        SAXException - The application may raise an exception.
      • notationDecl

        public void notationDecl​(String name,
                                 String publicId,
                                 String systemId)
                          throws SAXException
        Receive notification of a notation declaration event.

        It is up to the application to record the notation for later reference, if necessary.

        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.

        There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.

        Specified by:
        notationDecl in interface DTDHandler
        Overrides:
        notationDecl in class DefaultHandler
        Parameters:
        name - The notation name.
        publicId - The notation's public identifier, or null if none was given.
        systemId - The notation's system identifier, or null if none was given.
        Throws:
        SAXException - Any SAX exception, possibly wrapping another exception.
        See Also:
        unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String), AttributeList
      • getElementStack

        public org.dom4j.io.ElementStack getElementStack()
      • setElementStack

        public void setElementStack​(org.dom4j.io.ElementStack elementStack)
      • setEntityResolver

        public void setEntityResolver​(EntityResolver entityResolver)
      • setInputSource

        public void setInputSource​(InputSource inputSource)
      • isIncludeInternalDTDDeclarations

        public boolean isIncludeInternalDTDDeclarations()
        DOCUMENT ME!
        Returns:
        whether internal DTD declarations should be expanded into the DocumentType object or not.
      • setIncludeInternalDTDDeclarations

        public void setIncludeInternalDTDDeclarations​(boolean include)
        Sets whether internal DTD declarations should be expanded into the DocumentType object or not.
        Parameters:
        include - whether or not DTD declarations should be expanded and included into the DocumentType object.
      • isIncludeExternalDTDDeclarations

        public boolean isIncludeExternalDTDDeclarations()
        DOCUMENT ME!
        Returns:
        whether external DTD declarations should be expanded into the DocumentType object or not.
      • setIncludeExternalDTDDeclarations

        public void setIncludeExternalDTDDeclarations​(boolean include)
        Sets whether DTD external declarations should be expanded into the DocumentType object or not.
        Parameters:
        include - whether or not DTD declarations should be expanded and included into the DocumentType object.
      • isMergeAdjacentText

        public boolean isMergeAdjacentText()
        Returns whether adjacent text nodes should be merged together.
        Returns:
        Value of property mergeAdjacentText.
      • setMergeAdjacentText

        public void setMergeAdjacentText​(boolean mergeAdjacentText)
        Sets whether or not adjacent text nodes should be merged together when parsing.
        Parameters:
        mergeAdjacentText - New value of property mergeAdjacentText.
      • isStripWhitespaceText

        public boolean isStripWhitespaceText()
        Sets whether whitespace between element start and end tags should be ignored
        Returns:
        Value of property stripWhitespaceText.
      • setStripWhitespaceText

        public void setStripWhitespaceText​(boolean stripWhitespaceText)
        Sets whether whitespace between element start and end tags should be ignored.
        Parameters:
        stripWhitespaceText - New value of property stripWhitespaceText.
      • isIgnoreComments

        public boolean isIgnoreComments()
        Returns whether we should ignore comments or not.
        Returns:
        boolean
      • setIgnoreComments

        public void setIgnoreComments​(boolean ignoreComments)
        Sets whether we should ignore comments or not.
        Parameters:
        ignoreComments - whether we should ignore comments or not.
      • completeCurrentTextNode

        protected void completeCurrentTextNode()
        If the current text buffer contains any text then create a new text node with it and add it to the current element
      • createDocument

        protected Document createDocument()
        DOCUMENT ME!
        Returns:
        the current document
      • isIgnorableEntity

        protected boolean isIgnorableEntity​(String name)
        a Strategy Method to determine if a given entity name is ignorable
        Parameters:
        name - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • addDeclaredNamespaces

        protected void addDeclaredNamespaces​(Element element)
        Add all namespaces declared before the startElement() SAX event to the current element so that they are available to child elements and attributes
        Parameters:
        element - DOCUMENT ME!
      • addAttributes

        protected void addAttributes​(Element element,
                                     Attributes attributes)
        Add all the attributes to the given elements
        Parameters:
        element - DOCUMENT ME!
        attributes - DOCUMENT ME!
      • addDTDDeclaration

        protected void addDTDDeclaration​(Decl declaration)
        Adds an internal DTD declaration to the list of declarations
        Parameters:
        declaration - DOCUMENT ME!
      • addExternalDTDDeclaration

        protected void addExternalDTDDeclaration​(Decl declaration)
        Adds an external DTD declaration to the list of declarations
        Parameters:
        declaration - DOCUMENT ME!
      • createElementStack

        protected org.dom4j.io.ElementStack createElementStack()