Class MathMLParserSupport


  • @ThreadSafe
    public final class MathMLParserSupport
    extends java.lang.Object
    Utility class for the support parsing MathML and OpenDocument Formula (ODF) files.

    This class supports parsing of files that are either MathML or OpenDocument Formula (ODF) files. It also supports parsing MathML from a given text string.

    Version:
    $Revision: 96cb88e4e122 $
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.xml.parsers.DocumentBuilder createDocumentBuilder()
      Creates a DocumentBuilder that can be used to parse MathML documents into a standard DOM model.
      static org.w3c.dom.Document parseFile​(java.io.File inFile)
      Parse an input file and return the DOM tree.
      static org.w3c.dom.Document parseInputStreamODF​(java.io.InputStream inStream)
      Parse an input stream in ODF format.
      static org.w3c.dom.Document parseInputStreamXML​(java.io.InputStream inStream)
      Parse an input stream in MathML XML format.
      static org.w3c.dom.Document parseString​(java.lang.String content)
      Create a DOM Document from a given string containing MathML content.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder createDocumentBuilder()
                                                                       throws javax.xml.parsers.ParserConfigurationException
        Creates a DocumentBuilder that can be used to parse MathML documents into a standard DOM model.
        Returns:
        a DocumentBuilder instance that is configured for MathML
        Throws:
        javax.xml.parsers.ParserConfigurationException - if the builder could not be configured properly.
      • parseInputStreamXML

        public static org.w3c.dom.Document parseInputStreamXML​(java.io.InputStream inStream)
                                                        throws org.xml.sax.SAXException,
                                                               java.io.IOException
        Parse an input stream in MathML XML format.
        Parameters:
        inStream - the stream to parse.
        Returns:
        the DOM Tree
        Throws:
        org.xml.sax.SAXException - if a parse error occurs.
        java.io.IOException - if a read I/O error occurs.
      • parseInputStreamODF

        public static org.w3c.dom.Document parseInputStreamODF​(java.io.InputStream inStream)
                                                        throws org.xml.sax.SAXException,
                                                               java.io.IOException
        Parse an input stream in ODF format.
        Parameters:
        inStream - the stream to parse.
        Returns:
        the DOM Tree
        Throws:
        org.xml.sax.SAXException - if a parse error occurs.
        java.io.IOException - if a read I/O error occurs.
      • parseFile

        public static org.w3c.dom.Document parseFile​(java.io.File inFile)
                                              throws org.xml.sax.SAXException,
                                                     java.io.IOException
        Parse an input file and return the DOM tree.

        This function will auto-detect if the given input is in MathML or ODF format.

        Parameters:
        inFile - the file to parse.
        Returns:
        the DOM Tree
        Throws:
        org.xml.sax.SAXException - if a parse error occurs.
        java.io.IOException - if a read I/O error occurs.
      • parseString

        public static org.w3c.dom.Document parseString​(java.lang.String content)
                                                throws org.xml.sax.SAXException,
                                                       javax.xml.parsers.ParserConfigurationException,
                                                       java.io.IOException
        Create a DOM Document from a given string containing MathML content. This function uses a DOM Parser configured for MathML.
        Parameters:
        content - A String containing MathML.
        Returns:
        a DOM Document.
        Throws:
        org.xml.sax.SAXException - a parsing error occurred.
        javax.xml.parsers.ParserConfigurationException - a configuration error occurred.
        java.io.IOException - for any other IO exception.