public class MathMLContentParser
extends java.lang.Object
put(String, TagHandler)
methods.
Various parse methods are available for parsing complete documents or fragments of mathml code.
To enable mathml documents containing entities like π to be processed
the setPreprendMathMLEntities(boolean)
method can be called, if true a simple doctype
declaration defining the entities is inserted at the start of the document.
Modifier and Type | Class and Description |
---|---|
static class |
MathMLContentParser.Behaviour |
Constructor and Description |
---|
MathMLContentParser(Jep jep)
Creates a standard MathML parser.
|
MathMLContentParser(Jep jep,
javax.xml.parsers.SAXParserFactory spf,
MathMLDocumentHandler mdh)
Creates a MathML parser with a given parser factory and MathMLDocumentHandler.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getMathMLEntitiesString()
Returns a string sith a simple DOCTYPE declaration with defined entities.
|
javax.xml.parsers.SAXParserFactory |
getSAXParserFactory() |
boolean |
isPreprendMathMLEntities() |
java.lang.Object |
parseAll(org.xml.sax.InputSource is,
TagHandler unknownHandler)
Parse a document containing one or more math tags, with one or more child elements.
|
java.lang.Object |
parseAll(java.io.Reader reader,
MathMLContentParser.Behaviour behaviour)
Parse a complete xml document containing one or more math tags, with one or more child elements.
|
java.lang.Object |
parseAll(java.io.Reader reader,
TagHandler unknownHandler)
Parse a complete xml document containing one or more math tags, with one or more child elements.
|
java.util.List<Node> |
parseAllMath(org.xml.sax.InputSource is)
Parse a document containing one or more math tags, with one or more child elements.
|
java.util.List<Node> |
parseAllMath(java.io.Reader reader)
Parse a document containing one or more math tags, with one or more child elements.
|
java.util.List<Node> |
parseAllMath(java.lang.String xml)
Parse a document containing one or more math tags, with one or more child elements.
|
Node |
parseFragment(org.xml.sax.InputSource is)
Parse a document containing a mathml fragment, not enclosed in a math tag.
|
Node |
parseFragment(java.io.Reader reader)
Parse a document containing a mathml fragment, not enclosed in a math tag.
|
Node |
parseSingle(org.xml.sax.InputSource is)
Parse a document containing a single <math> element with a single child node.
|
Node |
parseSingle(java.io.Reader reader)
Parse a document containing a single <math> element with a single child node.
|
Node |
parseSingle(java.lang.String xml)
Parse a document containing a single <math> element with a single child node.
|
TagHandler |
put(java.lang.String key,
TagHandler handler)
Adds the handler for a given element
|
TagHandler |
putConstantElement(java.lang.String key,
java.lang.String jepName)
Add a handler for elements representing a constant.
|
TagHandler |
putEntity(java.lang.String entityName,
java.lang.String unicode,
java.lang.String jepVariableName)
Adds a handler for a MathML Entity representing a constant.
|
TagHandler |
putFunction(java.lang.String key,
java.lang.String jepName)
Adds a handler for a Jep function, uses the standardFunctionHandler
|
TagHandler |
putOperator(java.lang.String key,
Operator op)
Adds a handler for a Jep operator, uses the operatorHandler
|
TagHandler |
putSpecialNode(java.lang.String key,
int nchildren)
Adds a handler for special nodes like <sep/>, <logbase> and >degree< which only have meaning inside other elements.
|
TagHandler |
remove(java.lang.Object key)
Remove the handler associated with a give mathml element.
|
TagHandler |
removeEntity(java.lang.Object key) |
void |
setPreprendMathMLEntities(boolean preprendMathMLEntities)
Whether to prepend a simple deceleration to the start of the document.
|
void |
setSAXParserFactory(javax.xml.parsers.SAXParserFactory spf) |
protected javax.xml.parsers.SAXParserFactory spf
protected MathMLDocumentHandler mdh
protected Jep jep
protected OperatorTableI ot
protected MathTagHandler mathElementHandler
protected UnSupportedHandler unsuportedHandler
protected ConstantHandler constantHandler
protected IdentifierHandler identifierHandler
protected OperatorHandler operatorHandler
protected ApplyHandler applyHandler
protected StandardFunctionHandler standardFunctionHandler
protected SpecialNodeHandler specialNodeHandler
protected MatrixHandler matrixHandler
protected DeclareHandler declareHandler
protected SemanticHandler semanticHandler
protected AnnotationHandler annotationHandler
protected java.lang.String mathMLEntitiesString
protected static final java.lang.String MathMLEntitiesStart
protected static final java.lang.String MathMLEntitiesEnd
protected java.util.Map<java.lang.String,java.lang.String> mathMLEntities
public MathMLContentParser(Jep jep, javax.xml.parsers.SAXParserFactory spf, MathMLDocumentHandler mdh)
public MathMLContentParser(Jep jep)
jep
- the Jep instancepublic Node parseSingle(org.xml.sax.InputSource is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
is
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- if document does not contain exactly one math tag, or any non mathml datajava.io.IOException
public Node parseSingle(java.io.Reader reader) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
reader
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- if document does not contain exactly one math tag, or any non mathml datajava.io.IOException
public Node parseSingle(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xml
- string containing mathmljavax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- if document does not contain exactly one math tag, or any non mathml datajava.io.IOException
public Node parseFragment(org.xml.sax.InputSource is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
is
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- If the document contains non mathml data.java.io.IOException
public Node parseFragment(java.io.Reader reader) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
reader
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
- If the document contains non mathml data.java.io.IOException
public java.util.List<Node> parseAllMath(org.xml.sax.InputSource is) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
is
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public java.util.List<Node> parseAllMath(java.io.Reader reader) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
reader
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public java.util.List<Node> parseAllMath(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xml
- String with MathML.javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public java.lang.Object parseAll(org.xml.sax.InputSource is, TagHandler unknownHandler) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
is
- unknownHandler
- a handler for unknown elementsjavax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public java.lang.Object parseAll(java.io.Reader reader, TagHandler unknownHandler) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
reader
- the Reader to read fromunknownHandler
- a handler for unknown elementsjavax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public java.lang.Object parseAll(java.io.Reader reader, MathMLContentParser.Behaviour behaviour) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
reader
- the Reader to read frombehaviour
- javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
public TagHandler put(java.lang.String key, TagHandler handler)
key
- the name of the elementhandler
- the handler used for this type of elementpublic TagHandler putOperator(java.lang.String key, Operator op)
key
- the name of the mathml elementop
- the jep operatorpublic TagHandler putFunction(java.lang.String key, java.lang.String jepName)
key
- name of the MathML elementjepName
- name of the function used in jeppublic TagHandler putConstantElement(java.lang.String key, java.lang.String jepName)
key
- the name of the mathml elementjepName
- name of the variable used in jeppublic TagHandler putSpecialNode(java.lang.String key, int nchildren)
SpecialNodeHandler
key
- tag namenchildren
- number of childrenpublic TagHandler remove(java.lang.Object key)
key
- name of elementpublic java.lang.String getMathMLEntitiesString()
public boolean isPreprendMathMLEntities()
public void setPreprendMathMLEntities(boolean preprendMathMLEntities)
preprendMathMLEntities
- putEntity(java.lang.String, java.lang.String, java.lang.String)
public TagHandler putEntity(java.lang.String entityName, java.lang.String unicode, java.lang.String jepVariableName)
entityName
- name of the entity, e.g. "ExponentialE"unicode
- unicode character for entity, "\\u2147"jepVariableName
- name of variable used in jep, "e"setPreprendMathMLEntities(boolean)
public TagHandler removeEntity(java.lang.Object key)
public javax.xml.parsers.SAXParserFactory getSAXParserFactory()
public void setSAXParserFactory(javax.xml.parsers.SAXParserFactory spf)
Copyright © 2018 Singular Systems http://www.singularsys.com/jep