Class InvisibleXmlParser


  • public class InvisibleXmlParser
    extends java.lang.Object
    A parser for a particular Invisible XML grammar.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String logcategory  
      net.sf.saxon.s9api.XdmNode modularGrammar  
    • Field Detail

      • modularGrammar

        public final net.sf.saxon.s9api.XdmNode modularGrammar
    • Method Detail

      • getIxmlVersion

        public java.lang.String getIxmlVersion()
      • getOptions

        public ParserOptions getOptions()
        Get the parser options.
        Returns:
        the parser options
      • isFromCompiledGrammar

        public boolean isFromCompiledGrammar()
        Was this parser constructed from a compiled grammar?
        Returns:
        true if it was
      • getMetadata

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getMetadata()
        Get metadata.

        Pragmas in the prolog that aren't recognized by the processor are returned as "data" pragmas associating a URI with (a list of) values.

        Returns:
        the metadata
      • getPragmas

        public java.util.List<org.nineml.coffeefilter.model.IPragma> getPragmas()
        Get the pragmas associated with this parser.
        Returns:
        the list of pragmas.
      • getException

        public java.lang.Exception getException()
        Return the exception that caused an attempt to build a parser to fail.

        If the attempt was successful, or if failure did not raise an exception, null will be returned.

        Returns:
        the exception, or null if no exception is available
      • getParseTime

        public long getParseTime()
        Get the time spent parsing the input grammar.

        This returns the number of milliseconds of "wall clock time" spent by the processor constructing this parser.

        Returns:
        the time in milliseconds
      • constructed

        public boolean constructed()
        Did the grammar parse succeed?
        Returns:
        true if the parse succeeded
      • getHygieneReport

        public org.nineml.coffeegrinder.parser.HygieneReport getHygieneReport()
        Get the hygiene report for this parser's grammar
        Returns:
        the hygiene report
      • getFailedParse

        public InvisibleXmlDocument getFailedParse()
        If the attempt to parse the grammar failed, return a representation of that failure.
        Returns:
        The failed parse, or null if the parse succeeded.
      • parse

        public InvisibleXmlDocument parse​(java.net.URI source)
                                   throws java.io.IOException
        Get a document from a URI.

        Attempts to read from the URI with source.toURL().openConnection(). Assumes the input is in UTF-8.

        Parameters:
        source - the source
        Returns:
        a document
        Throws:
        java.io.IOException - If the source cannot be read
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.File source)
                                   throws java.io.IOException
        Get a document from a file.

        Assumes the input is in UTF-8.

        Parameters:
        source - the source
        Returns:
        a document
        Throws:
        java.io.IOException - If the source cannot be read
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.net.URI source,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a URI with an explicit encoding.

        Attempts to read from the URI with source.toURL().openConnection().

        Parameters:
        source - the source
        encoding - the encoding
        Returns:
        a document
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.File source,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a file with an explicit encoding.
        Parameters:
        source - the source
        encoding - the encoding
        Returns:
        a document
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.InputStream stream,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a stream.
        Parameters:
        stream - The input.
        encoding - The input encoding.
        Returns:
        A document.
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.lang.String input)
        Get a document from a string.
        Parameters:
        input - The input.
        Returns:
        A document.
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(org.nineml.coffeegrinder.tokens.Token[] input)
        Get a document from an array of tokens.
        Parameters:
        input - The input.
        Returns:
        A document.
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • getGrammar

        public org.nineml.coffeegrinder.parser.Grammar getGrammar()
        Get the underlying grammar
        Returns:
        the underlying CoffeeGrinder grammar
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • readInputStream

        public java.lang.String readInputStream​(java.io.InputStream stream,
                                                java.lang.String charset)
                                         throws java.io.IOException
        Throws:
        java.io.IOException