Class MathMLContentBuilder
- java.lang.Object
-
- com.singularsys.extensions.mathml.MathMLContentBuilder
-
- All Implemented Interfaces:
MathMLDocumentBuilder
public class MathMLContentBuilder extends java.lang.Object implements MathMLDocumentBuilder
Main class for the Content MathML builder.- Author:
- Richard Morris
-
-
Constructor Summary
Constructors Constructor Description MathMLContentBuilder(Jep jep)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.ElementbuildChild(Node n, org.w3c.dom.Document d)Builds a Element representing a Jep sub-expression.org.w3c.dom.DocumentbuildDocument(Node node)Create a document containing an single math tag with a single child, no namespace is used.org.w3c.dom.DocumentbuildDocument(Node node, boolean useNamespace)Create a document containing an single math tag with a single child, no namespace is used.org.w3c.dom.DocumentbuildDocument(Node node, boolean useNamespace, javax.xml.parsers.DocumentBuilder docb)Create a document containing an single math tag with a single child, if useNamespace is set then the standard MathML namespace is used.org.w3c.dom.DocumentbuildDocument(Node node, java.lang.String prefix)Builds a document using a given namespace prefixorg.w3c.dom.DocumentbuildDocument(Node node, java.lang.String prefix, javax.xml.parsers.DocumentBuilder docb)org.w3c.dom.ElementbuildMathElement(Node[] nodes, org.w3c.dom.Document d, boolean useNamespace)Builds a <math> element with one child element per node.org.w3c.dom.ElementbuildMathElement(Node[] nodes, org.w3c.dom.Document d, java.lang.String prefix)Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefixorg.w3c.dom.ElementbuildMathElement(Node node, org.w3c.dom.Document d, boolean useNamespace)Builds a <math> element with a single child element, with content mark up for the Jep expression.org.w3c.dom.ElementbuildMathElement(Node node, org.w3c.dom.Document d, java.lang.String prefix)Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefixorg.w3c.dom.ElementcreateElement(java.lang.String name, org.w3c.dom.Document doc)Create an element using the MAthML namespaces if needed.javax.xml.parsers.DocumentBuilderFactorygetDocumentBuilderFactory()NumberBuilder.DoubleBehaviourgetDoubleBehaviour()FunctionBuildergetFunctionBuilder()java.lang.StringgetNamespacePrefix()NumberBuildergetNumberBuilder()OperatorBuildergetOperatorBuilder()VariableBuildergetVaribleBuilder()org.w3c.dom.DocumentnewDocument()Create an empty document.org.w3c.dom.DocumentnewDocumentMathMLDTD()Create a document with the MathML DTD and a <math> tag as the root element.org.w3c.dom.DocumentnewDocumentMathMLDTD(java.lang.String systemID)Create a document with the MathML DTD with the specified systemID and a <math> tag as the root element.java.lang.StringputConstant(java.lang.String key, java.lang.String value)java.lang.StringputEntity(java.lang.String key, java.lang.String value)MathMLFragmentBuilderputFunction(java.lang.String key, MathMLFragmentBuilder value)java.lang.StringputFunction(java.lang.String key, java.lang.String value)MathMLFragmentBuilderputOperator(Operator key, MathMLFragmentBuilder value)java.lang.StringputOperator(Operator key, java.lang.String value)voidsetAttribute(org.w3c.dom.Element e, java.lang.String name, java.lang.String value)Sets an element attribute using namespaces if required.voidsetDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory dbf)voidsetDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour)Sets how double values with integral values are represented.voidsetFunctionBuilder(FunctionBuilder functionBuilder)voidsetNamespacePrefix(java.lang.String namespacePrefix)voidsetNumberBuilder(NumberBuilder numberBuilder)voidsetOperatorBuilder(OperatorBuilder operatorBuilder)voidsetVaribleBuilder(VariableBuilder varibleBuilder)
-
-
-
Constructor Detail
-
MathMLContentBuilder
public MathMLContentBuilder(Jep jep) throws javax.xml.parsers.ParserConfigurationException
- Throws:
javax.xml.parsers.ParserConfigurationException
-
-
Method Detail
-
newDocument
public org.w3c.dom.Document newDocument()
Create an empty document.- Returns:
- a new empty document
-
newDocumentMathMLDTD
public org.w3c.dom.Document newDocumentMathMLDTD()
Create a document with the MathML DTD and a <math> tag as the root element. UseDocument jepDoc = db.newDocumentMathMLDTD(); Element e = db.buildChild(jepNode, jepDoc); jepDoc.getDocumentElement().appendChild(e);to add contents.- Returns:
- a new document
-
newDocumentMathMLDTD
public org.w3c.dom.Document newDocumentMathMLDTD(java.lang.String systemID)
Create a document with the MathML DTD with the specified systemID and a <math> tag as the root element. UseDocument jepDoc = db.newDocumentMathMLDTD(); Element e = db.buildChild(jepNode, jepDoc); jepDoc.getDocumentElement().appendChild(e);to add contents.- Parameters:
systemID- the systemID to use- Returns:
- a new document
-
buildDocument
public org.w3c.dom.Document buildDocument(Node node) throws JepException
Create a document containing an single math tag with a single child, no namespace is used.- Parameters:
node- jep node for expression- Returns:
- a new document
- Throws:
JepException
-
buildDocument
public org.w3c.dom.Document buildDocument(Node node, boolean useNamespace) throws JepException
Create a document containing an single math tag with a single child, no namespace is used.- Parameters:
node- jep node for expressionuseNamespace-- Returns:
- a new document
- Throws:
JepException
-
buildDocument
public org.w3c.dom.Document buildDocument(Node node, boolean useNamespace, javax.xml.parsers.DocumentBuilder docb) throws JepException
Create a document containing an single math tag with a single child, if useNamespace is set then the standard MathML namespace is used.- Parameters:
node-useNamespace-docb-- Returns:
- a new document
- Throws:
JepException
-
buildDocument
public org.w3c.dom.Document buildDocument(Node node, java.lang.String prefix) throws JepException
Builds a document using a given namespace prefix- Parameters:
node-prefix-- Returns:
- a new document
- Throws:
JepException
-
buildDocument
public org.w3c.dom.Document buildDocument(Node node, java.lang.String prefix, javax.xml.parsers.DocumentBuilder docb) throws JepException
- Throws:
JepException
-
buildMathElement
public org.w3c.dom.Element buildMathElement(Node node, org.w3c.dom.Document d, boolean useNamespace) throws JepException
Builds a <math> element with a single child element, with content mark up for the Jep expression.- Parameters:
node- Jep expressiond- the documentuseNamespace- use the standard MathML namespace- Returns:
- a new element representing the Jep expression
- Throws:
JepException
-
buildMathElement
public org.w3c.dom.Element buildMathElement(Node[] nodes, org.w3c.dom.Document d, boolean useNamespace) throws JepException
Builds a <math> element with one child element per node.- Parameters:
nodes- an array of Jep expressionsd- the documentuseNamespace- whether to use the standard MathML namespace.- Returns:
- a new element representing the Jep expression
- Throws:
JepException
-
buildMathElement
public org.w3c.dom.Element buildMathElement(Node node, org.w3c.dom.Document d, java.lang.String prefix) throws JepException
Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefix- Parameters:
node- Jep expressiond- the document to create elements inprefix- the namespace-prefix to use the prefix will be attached to all MathML elements and attributes- Returns:
- DOM element for the math tag
- Throws:
JepException
-
buildMathElement
public org.w3c.dom.Element buildMathElement(Node[] nodes, org.w3c.dom.Document d, java.lang.String prefix) throws JepException
Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefix- Parameters:
nodes- an array of Jep expressionsd- the document to create elements inprefix- the namespace-prefix to use the prefix will be attached to all MathML elements and attributes- Returns:
- DOM element for the math tag
- Throws:
JepException
-
buildChild
public org.w3c.dom.Element buildChild(Node n, org.w3c.dom.Document d) throws JepException
Builds a Element representing a Jep sub-expression.- Specified by:
buildChildin interfaceMathMLDocumentBuilder- Parameters:
n- the jep noded- the document to create the element in.- Returns:
- element representing the node
- Throws:
JepException
-
createElement
public org.w3c.dom.Element createElement(java.lang.String name, org.w3c.dom.Document doc)Create an element using the MAthML namespaces if needed. If namespacePrefix is set then MathML namespace will be used and Document.createElementNS is called.- Specified by:
createElementin interfaceMathMLDocumentBuilder- Parameters:
name- local name of element without prefix.doc- document to create an element in.- Returns:
- a new Element
-
setAttribute
public void setAttribute(org.w3c.dom.Element e, java.lang.String name, java.lang.String value)Sets an element attribute using namespaces if required. If namespacePrefix is set then MathML namespace will be used and Element.setAttributeNS is called.- Specified by:
setAttributein interfaceMathMLDocumentBuilder- Parameters:
e- element to set an attribut ofname- name of attributevalue- value of attribute
-
getNumberBuilder
public NumberBuilder getNumberBuilder()
-
setNumberBuilder
public void setNumberBuilder(NumberBuilder numberBuilder)
-
getVaribleBuilder
public VariableBuilder getVaribleBuilder()
-
setVaribleBuilder
public void setVaribleBuilder(VariableBuilder varibleBuilder)
-
putConstant
public java.lang.String putConstant(java.lang.String key, java.lang.String value)
-
putEntity
public java.lang.String putEntity(java.lang.String key, java.lang.String value)
-
putOperator
public MathMLFragmentBuilder putOperator(Operator key, MathMLFragmentBuilder value)
-
putOperator
public java.lang.String putOperator(Operator key, java.lang.String value)
-
putFunction
public MathMLFragmentBuilder putFunction(java.lang.String key, MathMLFragmentBuilder value)
-
putFunction
public java.lang.String putFunction(java.lang.String key, java.lang.String value)
-
getDocumentBuilderFactory
public javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
-
setDocumentBuilderFactory
public void setDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory dbf)
-
getNamespacePrefix
public java.lang.String getNamespacePrefix()
-
setNamespacePrefix
public void setNamespacePrefix(java.lang.String namespacePrefix)
-
getFunctionBuilder
public FunctionBuilder getFunctionBuilder()
-
setFunctionBuilder
public void setFunctionBuilder(FunctionBuilder functionBuilder)
-
getOperatorBuilder
public OperatorBuilder getOperatorBuilder()
-
setOperatorBuilder
public void setOperatorBuilder(OperatorBuilder operatorBuilder)
-
getDoubleBehaviour
public NumberBuilder.DoubleBehaviour getDoubleBehaviour()
-
setDoubleBehaviour
public void setDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour)
Sets how double values with integral values are represented.- ALLWAYS_DOUBLE <cn>2.0</cn>
- NO_DECIMALPOINT <cn>2.0</cn>
- TYPE_INTEGER <cn type="integer">2</cn>
- Parameters:
doubleBehaviour-
-
-