Interface XMLDepictContext

    • Method Detail

      • getQualifiedName

        java.lang.String getQualifiedName​(java.net.URI namespaceURI,
                                          java.lang.String localName)
        Retrieves the qualified name of the given namespace and local name. If the namespace URI is not recognized, a new prefix will be generated for that namespace This method therefore works for attributes in the null namespace, but cannot work for elements in the null namespace because this would be ambiguous with elements in the the XHTML namespace.
        Parameters:
        namespaceURI - The URI of the XML namespace, or null if there is no namespace and there should be no prefix.
        localName - The local name of the element or attribute with no prefix.
        Returns:
        The XML qualified name.
      • writeDocType

        void writeDocType​(boolean writeXMLDeclaration,
                          java.net.URI namespaceURI,
                          java.lang.String localName)
                   throws java.io.IOException
        Writes a doctype along with an optional XML declaration to the string builder and sets the output content type. No system ID or public ID will be written.
        Parameters:
        writeXMLDeclaration - Whether an XML declaration should be included before the doctype.
        namespaceURI - The URI of the XML namespace of document element, or null if there is no namespace.
        localName - The local name of the document element with no prefix.
        Throws:
        java.io.IOException - if there is an error writing the information.
      • writeDocType

        void writeDocType​(boolean writeXMLDeclaration,
                          java.net.URI namespaceURI,
                          java.lang.String localName,
                          com.globalmentor.net.ContentType contentType)
                   throws java.io.IOException
        Writes a doctype along with an optional XML declaration to the string builder and sets the output content type. No system ID or public ID will be written.
        Parameters:
        writeXMLDeclaration - Whether an XML declaration should be included before the doctype.
        namespaceURI - The URI of the XML namespace of document element, or null if there is no namespace.
        localName - The local name of the document element with no prefix.
        contentType - The specific XML content type.
        Throws:
        java.lang.NullPointerException - if the given content type is null.
        java.io.IOException - if there is an error writing the information.
      • writeDocType

        void writeDocType​(boolean writeXMLDeclaration,
                          java.net.URI namespaceURI,
                          java.lang.String localName,
                          java.lang.String publicID)
                   throws java.io.IOException
        Writes a doctype along with an optional XML declaration to the string builder and sets the output content type. The system ID and content type will be determined from the given public ID.
        Parameters:
        writeXMLDeclaration - Whether an XML declaration should be included before the doctype.
        namespaceURI - The URI of the XML namespace of document element, or null if there is no namespace.
        localName - The local name of the document element with no prefix.
        publicID - The XML declaration public ID.
        Throws:
        java.lang.NullPointerException - if the given public ID is null.
        java.lang.IllegalArgumentException - if a system ID could not be determined from the given public ID.
        java.io.IOException - if there is an error writing the information.
      • writeDocType

        void writeDocType​(boolean writeXMLDeclaration,
                          java.net.URI namespaceURI,
                          java.lang.String localName,
                          java.lang.String publicID,
                          java.lang.String systemID,
                          com.globalmentor.net.ContentType contentType)
                   throws java.io.IOException
        Writes a doctype along with an optional XML declaration to the string builder and sets the output content type.
        Parameters:
        writeXMLDeclaration - Whether an XML declaration should be included before the doctype.
        namespaceURI - The URI of the XML namespace of document element, or null if there is no namespace.
        localName - The local name of the document element with no prefix.
        publicID - The XML declaration public ID, or null if none is used.
        systemID - The XML declaration system ID, or null if one can be determined from the given public ID.
        contentType - The specific XML content type, or null if a content type should be determined from the public ID; otherwise will default to "text/xml".
        Throws:
        java.lang.IllegalArgumentException - if a system ID was not provided or one could not be determined from the given public ID.
        java.io.IOException - if there is an error writing the information.
      • writeElementBegin

        XMLDepictContext.ElementState writeElementBegin​(java.net.URI namespaceURI,
                                                        java.lang.String localName)
                                                 throws java.io.IOException
        Begins an XML element that will not be an empty element, even if it has no content.
        Parameters:
        namespaceURI - The URI of the XML namespace of the element, or null if there is no namespace.
        localName - The local name of the element with no prefix.
        Returns:
        The state of the element being written.
        Throws:
        java.io.IOException - if there is an error writing the information.
      • writeElementBegin

        XMLDepictContext.ElementState writeElementBegin​(java.net.URI namespaceURI,
                                                        java.lang.String localName,
                                                        boolean isEmptyElementAllowed)
                                                 throws java.io.IOException
        Begins an XML element, specifying whether an empty element is allowed.
        Parameters:
        namespaceURI - The URI of the XML namespace of the element, or null if there is no namespace.
        localName - The local name of the element with no prefix.
        isEmptyElementAllowed - Whether an empty element can be created if there is no content.
        Returns:
        The state of the element being written.
        Throws:
        java.io.IOException - if there is an error writing the information.
      • writeElementEnd

        XMLDepictContext.ElementState writeElementEnd​(java.net.URI namespaceURI,
                                                      java.lang.String localName)
                                               throws java.io.IOException
        Ends an XML element.
        Parameters:
        namespaceURI - The URI of the XML namespace of the element, or null if there is no namespace.
        localName - The local name of the element with no prefix.
        Returns:
        The state of the element being written.
        Throws:
        java.util.NoSuchElementException - if the element state stack is empty.
        java.lang.IllegalStateException - if the given namespace URI and/or local name does not match that of the currently open element.
        java.io.IOException - if there is an error writing the information.
      • writeAttribute

        void writeAttribute​(java.net.URI namespaceURI,
                            java.lang.String localName,
                            java.lang.String value)
                     throws java.io.IOException
        Writes an attribute of an XML element. The attribute value will be properly encoded for XML.
        Parameters:
        namespaceURI - The URI of the XML namespace of the attribute, or null if there is no namespace.
        localName - The local name of the attribute with no prefix.
        value - The unencoded value of the attribute.
        Throws:
        java.util.NoSuchElementException - if the element state stack is empty.
        java.io.IOException - if there is an error writing the information.
      • writeCommentOpen

        void writeCommentOpen()
                       throws java.io.IOException
        Writes the beginning part of an XML comment.
        Throws:
        java.lang.IllegalStateException - if the comment has already been opened but not closed.
        java.io.IOException - if there is an error writing the information.
        See Also:
        writeCommentClose()
      • writeCommentClose

        void writeCommentClose()
                        throws java.io.IOException
        Writes the ending part of an XML comment.
        Throws:
        java.lang.IllegalStateException - if the comment has not been opened or has already been closed.
        java.io.IOException - if there is an error writing the information.
        See Also:
        writeCommentOpen()
      • writeComment

        void writeComment​(java.lang.String comment)
                   throws java.io.IOException
        Writes an XML comment. This method ensures that any open beginning tag has been closed.
        Parameters:
        comment - The comment to write.
        Throws:
        java.io.IOException - if there is an error writing the information.
        See Also:
        writeCommentOpen(), writeCommentClose()