Class MathMLContentBuilder
java.lang.Object
com.singularsys.extensions.mathml.MathMLContentBuilder
- All Implemented Interfaces:
MathMLDocumentBuilder
Main class for the Content MathML builder.
- Author:
- Richard Morris
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildChild(Node n, Document d) Builds an Element representing a Jep sub-expression.buildDocument(Node node) Create a document containing a single math tag with a single child, no namespace is used.buildDocument(Node node, boolean useNamespace) Create a document containing a single math tag with a single child, no namespace is used.buildDocument(Node node, boolean useNamespace, DocumentBuilder docb) Create a document containing a single math tag with a single child, if useNamespace is set then the standard MathML namespace is used.buildDocument(Node node, String prefix) Builds a document using a given namespace prefixbuildDocument(Node node, String prefix, DocumentBuilder docb) buildMathElement(Node[] nodes, Document d, boolean useNamespace) Builds a <math> element with one child element per node.buildMathElement(Node[] nodes, Document d, String prefix) Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefixbuildMathElement(Node node, Document d, boolean useNamespace) Builds a <math> element with a single child element, with content mark up for the Jep expression.buildMathElement(Node node, Document d, String prefix) Builds a <math> element with a single child, the standard MathML namespace and a specified namespace prefixcreateElement(String name, Document doc) Create an element using the MAthML namespaces if needed.Create an empty document.Create a document with the MathML DTD and a <math> tag as the root element.newDocumentMathMLDTD(String systemID) Create a document with the MathML DTD with the specified systemID and a <math> tag as the root element.putConstant(String key, String value) putFunction(String key, MathMLFragmentBuilder value) putFunction(String key, String value) putOperator(Operator key, MathMLFragmentBuilder value) putOperator(Operator key, String value) voidsetAttribute(Element e, String name, String value) Sets an element attribute using namespaces if required.voidvoidsetDoubleBehaviour(NumberBuilder.DoubleBehaviour doubleBehaviour) Sets how double values with integral values are represented.voidsetFunctionBuilder(FunctionBuilder functionBuilder) voidsetNamespacePrefix(String namespacePrefix) voidsetNumberBuilder(NumberBuilder numberBuilder) voidsetOperatorBuilder(OperatorBuilder operatorBuilder) voidsetVariableBuilder(VariableBuilder variableBuilder)
-
Constructor Details
-
MathMLContentBuilder
- Throws:
ParserConfigurationException
-
-
Method Details
-
newDocument
Create an empty document.- Returns:
- a new empty 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
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
Create a document containing a single math tag with a single child, no namespace is used.- Parameters:
node- jep node for expression- Returns:
- a new document
- Throws:
JepException
-
buildDocument
Create a document containing a 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 Document buildDocument(Node node, boolean useNamespace, DocumentBuilder docb) throws JepException Create a document containing a 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
Builds a document using a given namespace prefix- Parameters:
node-prefix-- Returns:
- a new document
- Throws:
JepException
-
buildDocument
- Throws:
JepException
-
buildMathElement
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
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
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
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
Builds an 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
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
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 attribute ofname- name of attributevalue- value of attribute
-
getNumberBuilder
-
setNumberBuilder
-
getVariableBuilder
-
setVariableBuilder
-
putConstant
-
putEntity
-
putOperator
-
putOperator
-
putFunction
-
putFunction
-
getDocumentBuilderFactory
-
setDocumentBuilderFactory
-
getNamespacePrefix
-
setNamespacePrefix
-
getFunctionBuilder
-
setFunctionBuilder
-
getOperatorBuilder
-
setOperatorBuilder
-
getDoubleBehaviour
-
setDoubleBehaviour
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-
-