Class DoctypeInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class DoctypeInputStream
    extends InputStream
    Adapts the marked-up content in a source InputStream to specify that it conforms to a different DTD. Combines InputStream semantics with the ability to specify a target doctype for a byte stream containing XML markup. Used by Validator class to wrap an InputStream, when performing validation of a document against a DTD.
    • Constructor Detail

      • DoctypeInputStream

        public DoctypeInputStream​(InputStream originalSource,
                                  String encoding,
                                  String doctypeName,
                                  String systemID)
        Create an InputStream whose XML content is provided by the originalSource with the exception of the DOCTYPE which is provided by the doctypeName and systemID.
        Parameters:
        originalSource - the original input
        doctypeName - name of the new doctype
        systemID - system id of the new doctype
        encoding - optional encoding of the input (defaults to platform encoding)
    • Method Detail

      • getContent

        protected String getContent​(String encoding)
                             throws IOException
        Parameters:
        encoding - optional encoding of the input (defaults to platform encoding)
        Returns:
        the content of the original source, without amendments or substitutions. Safe to call multiple times.
        Throws:
        IOException - if thrown while reading from the original source