public class MathMLUnificator extends Object
◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR).| Constructor and Description |
|---|
MathMLUnificator() |
| Modifier and Type | Method and Description |
|---|---|
static UnificationLevel |
getNodeUnificationLevel(Node node)
Determine the unification level of the
Node and max level of the
unification series. |
static HashMap<Integer,Node> |
getUnifiedMathMLNodes(Node mathNode,
boolean operatorUnification)
Transforms the given MathML
Node for series of MathML formulae
with leaf elements substituted gradually for a special unification
representing symbol ◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR). |
static boolean |
isUnifiedMathNode(Node node)
Test whether the given node is unified math node.
|
static void |
replaceNodeWithUnificator(Node oldNode)
Replace the given node with unification element containing unification
representing symbol
◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR). |
static void |
unifyMathML(Document doc,
boolean operatorUnification)
In the given W3C DOM represented XML document find all maths nodes (see
DocumentParser.findMathMLNodes(org.w3c.dom.Document)) and
substitute them for series of formulae with leaf elements substituted
gradually for a special unification representing symbol ◍
(for Presentation MathML, see Constants.PMATHML_UNIFICATOR) or
◐ (for Content MathML, see
Constants.CMATHML_UNIFICATOR). |
static void |
unifyMathML(InputStream is,
OutputStream os,
boolean operatorUnification)
In the given W3C DOM represented XML document find all maths nodes (see
DocumentParser.findMathMLNodes(org.w3c.dom.Document)) and
substitute them for series of formulae with leaf elements substituted
gradually for a special unification representing symbol ◍
(for Presentation MathML, see Constants.PMATHML_UNIFICATOR) or
◐ (for Content MathML, see
Constants.CMATHML_UNIFICATOR). |
static void |
unifyMathMLNode(Node mathNode,
boolean operatorUnification)
Substitute the given MathML
Node for series of MathML formulae
with leaf elements substituted gradually for a special unification
representing symbol ◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR). |
public static void unifyMathML(Document doc, boolean operatorUnification)
In the given W3C DOM represented XML document find all maths nodes (see
DocumentParser.findMathMLNodes(org.w3c.dom.Document)) and
substitute them for series of formulae with leaf elements substituted
gradually for a special unification representing symbol ◍
(for Presentation MathML, see Constants.PMATHML_UNIFICATOR) or
◐ (for Content MathML, see
Constants.CMATHML_UNIFICATOR).
Resulting series of the original and unified MathML nodes is itself
encapsulated in a new element <unified-math> (see
Constants.UNIFIED_MATHML_ROOT_ELEM) in XML namespace
http://mir.fi.muni.cz/mathml-unification/ (see
Constants.UNIFIED_MATHML_NS).
doc - W3C DOM representation of the XML document to work on.operatorUnification - If true unify also operator
nodes, otherwise keep operator nodes intact.DocumentParser.findMathMLNodes(org.w3c.dom.Document)public static void unifyMathML(InputStream is, OutputStream os, boolean operatorUnification) throws IOException
In the given W3C DOM represented XML document find all maths nodes (see
DocumentParser.findMathMLNodes(org.w3c.dom.Document)) and
substitute them for series of formulae with leaf elements substituted
gradually for a special unification representing symbol ◍
(for Presentation MathML, see Constants.PMATHML_UNIFICATOR) or
◐ (for Content MathML, see
Constants.CMATHML_UNIFICATOR).
Resulting series of the original and unified MathML nodes is itself
encapsulated in a new element <unified-math> (see
Constants.UNIFIED_MATHML_ROOT_ELEM) in XML namespace
http://mir.fi.muni.cz/mathml-unification/ (see
Constants.UNIFIED_MATHML_NS).
Untouched input will be returned and error logged in case of any error during the processing.
is - Input stream with UTF-8 encoded string representation of the
XML document to work on.os - Output stream to write UTF-8 encoded string representation of
the processed XML document.operatorUnification - If true unify also operator
nodes, otherwise keep operator nodes intact.IOException - If any I/O error occurs while reading the
input stream.DocumentParser.findMathMLNodes(org.w3c.dom.Document)public static void unifyMathMLNode(Node mathNode, boolean operatorUnification)
Substitute the given MathML Node for series of MathML formulae
with leaf elements substituted gradually for a special unification
representing symbol ◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR).
Resulting series of the original and unified MathML nodes is itself
encapsulated in a new element <unified-math> (see
Constants.UNIFIED_MATHML_ROOT_ELEM) in XML namespace
http://mir.fi.muni.cz/mathml-unification/ (see
Constants.UNIFIED_MATHML_NS).
mathNode - W3C DOM XML document representation attached MathML node
to work on.operatorUnification - If true unify also operator
nodes, otherwise keep operator nodes intact.public static HashMap<Integer,Node> getUnifiedMathMLNodes(Node mathNode, boolean operatorUnification)
Transforms the given MathML Node for series of MathML formulae
with leaf elements substituted gradually for a special unification
representing symbol ◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR).
mathNode - W3C DOM XML document representation attached MathML node
to work on.operatorUnification - If true unify also operator
nodes, otherwise keep operator nodes intact.mathNode with
key of the HashMap describing order (level of unification) of
elements in the collection.public static void replaceNodeWithUnificator(Node oldNode)
◍ (for Presentation MathML, see
Constants.PMATHML_UNIFICATOR) or ◐ (for Content
MathML, see Constants.CMATHML_UNIFICATOR).oldNode - The node to be replaced with the unification representing
element.IllegalArgumentException - If the given node does not have parent.public static boolean isUnifiedMathNode(Node node)
Test whether the given node is unified math node. The node is considered to be unified math node if
null,Constants.UNIFIED_MATHML_LEVEL_ATTR) in MathML Unification XML
namespace (see Constants.UNIFIED_MATHML_NS) with valid value,
i.e. integer greather than 0.
The method is XML namespace aware and expects the node DOM to be build as
XML aware (see
DocumentBuilderFactory.setNamespaceAware(boolean)).
In case the input DOM was created as namespace unaware or the input XML document does not correctly use namespaces the method tries to fall back to element-plain-name-only math node detection. The element is considered to be math element if
http://www.w3.org/1998/Math/MathML (see
Constants.MATHML_NS),<math> (see
Constants.UNIFIED_MATHML_ROOT_ELEM) without any namespace
definition.
node - The node to test.true if the above description is fulfilled,
false otherwise.public static UnificationLevel getNodeUnificationLevel(Node node)
Determine the unification level of the Node and max level of the
unification series. If the node does not possess the appropriate
unification level XML attributes the UnificationLevel object will
indicate that by having both UnificationLevel.nodeLevel and
UnificationLevel.maxLevel set to null.
Please note that only existance of valid unification level XML
attributes is tested. If you want to be sure the node is a valid unified
math node use isUnifiedMathNode(org.w3c.dom.Node)!
node - The node to determine the unification level for.UnificationLevel.unifyMathMLNode(org.w3c.dom.Node, boolean)Copyright © 2016. All rights reserved.