net.sourceforge.jeuclid
Class MathMLParserSupport

java.lang.Object
  extended by net.sourceforge.jeuclid.MathMLParserSupport

@ThreadSafe
public final class MathMLParserSupport
extends 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: 2bab6eb875e8 $

Method Summary
static DocumentBuilder createDocumentBuilder()
          Creates a DocumentBuilder that can be used to parse MathML documents into a standard DOM model.
static Document parseFile(File inFile)
          Parse an input file and return the DOM tree.
static Document parseInputStreamODF(InputStream inStream)
          Parse an input stream in ODF format.
static Document parseInputStreamXML(InputStream inStream)
          Parse an input stream in MathML XML format.
static Document parseString(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 DocumentBuilder createDocumentBuilder()
                                             throws 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:
ParserConfigurationException - if the builder could not be configured properly.

parseInputStreamXML

public static Document parseInputStreamXML(InputStream inStream)
                                    throws SAXException,
                                           IOException
Parse an input stream in MathML XML format.

Parameters:
inStream - the stream to parse.
Returns:
the DOM Tree
Throws:
SAXException - if a parse error occurs.
IOException - if a read I/O error occurs.

parseInputStreamODF

public static Document parseInputStreamODF(InputStream inStream)
                                    throws SAXException,
                                           IOException
Parse an input stream in ODF format.

Parameters:
inStream - the stream to parse.
Returns:
the DOM Tree
Throws:
SAXException - if a parse error occurs.
IOException - if a read I/O error occurs.

parseFile

public static Document parseFile(File inFile)
                          throws SAXException,
                                 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:
SAXException - if a parse error occurs.
IOException - if a read I/O error occurs.

parseString

public static Document parseString(String content)
                            throws SAXException,
                                   ParserConfigurationException,
                                   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:
SAXException - a parsing error occurred.
ParserConfigurationException - a configuration error occurred.
IOException - for any other IO exception.


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.