be.ugent.caagt.jmathtex.mathml

Class MathMLParser


public class MathMLParser
extends java.lang.Object

Provides various static methods for parsing MathML input from a file to a TeXFormula.

JDOM is used for parsing. For each "parse" method found here, there's a corresponding "build" method in the class org.jdom.input.SaxBuilder. For more information, see http://jdom.org .

Method Summary

protected static TeXFormula
createSpace(String[] attr)
protected static Color
getColor(String s)
protected static List
getFormulaList(List l, be.ugent.caagt.jmathtex.mathml.Environment env)
protected static Object
getUnicodeMapping(char unicode)
static TeXFormula
parse(File file, boolean validate)
Parses a MathML input file identified by a File.
static TeXFormula
parse(InputStream stream, String uri, boolean validate)
Parses MathML input from the specified InputStream and URI base.
static TeXFormula
parse(InputStream stream, boolean validate)
Parses MathML input from the specified InputStream.
static TeXFormula
parse(Reader reader, String uri, boolean validate)
Parses MathML input from the specified Reader and URI base.
static TeXFormula
parse(Reader reader, boolean validate)
Parses MathML input from the specified Reader.
static TeXFormula
parse(String uri, boolean validate)
Parses a MathML input file identified by the specified URI.
static TeXFormula
parse(URL url, boolean validate)
Parses a MathML input file identified by the specified URL.

Method Details

createSpace

protected static TeXFormula createSpace(String[] attr)
            throws MathMLException

getColor

protected static Color getColor(String s)
            throws MathMLException

getFormulaList

protected static List getFormulaList(List l,
                                                 be.ugent.caagt.jmathtex.mathml.Environment env)
            throws MathMLException

getUnicodeMapping

protected static Object getUnicodeMapping(char unicode)

parse

public static TeXFormula parse(File file,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses a MathML input file identified by a File.
Parameters:
file - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(InputStream stream,
                               String uri,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses MathML input from the specified InputStream and URI base.
Parameters:
stream - the stream to read from
uri - base for resolving relative URI's
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(InputStream stream,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses MathML input from the specified InputStream.
Parameters:
stream - the stream to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(Reader reader,
                               String uri,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses MathML input from the specified Reader and URI base.
Parameters:
reader - the Reader to read from
uri - base for resolving relative URI's
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(Reader reader,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses MathML input from the specified Reader.
Parameters:
reader - the Reader to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(String uri,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses a MathML input file identified by the specified URI.
Parameters:
uri - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct

parse

public static TeXFormula parse(URL url,
                               boolean validate)
            throws MathMLException,
                   IOException
Parses a MathML input file identified by the specified URL.
Parameters:
url - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct