public final class MathMLUtilities
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
ANNOTATION_LOCAL_NAME |
static java.lang.String |
ANNOTATION_XML_LOCAL_NAME |
| 构造器和说明 |
|---|
MathMLUtilities() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
convertExplicitFencesToMfenced(org.w3c.dom.Document document)
Converts explicit fences generated by SnuggleTeX back to
mfenced. |
static void |
convertMfencedToExplicitFences(org.w3c.dom.Document document)
Replaces every deprecated MathML
mfenced element in the supplied document with
its explicit mrow/mo equivalent. |
static void |
ensureMathMLContainer(org.w3c.dom.Element mathElement) |
static org.w3c.dom.Element |
ensureMathMLDocument(org.w3c.dom.Document document)
Checks that the given DOM
Document contains a single MathML math
Element. |
static java.lang.String |
extractAnnotationString(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
Extracts the first textual annotation found having the given encoding attribute from
the given MathML
math element, if such an annotation is found. |
static org.w3c.dom.NodeList |
extractAnnotationXML(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
Extracts the first XML-based annotation having the given encoding attribute from the given MathML
math element, if such an annotation is found. |
static org.w3c.dom.Element |
extractFirstSemanticsBranch(org.w3c.dom.Element mathElement) |
static boolean |
isMathMLElement(org.w3c.dom.Node node)
Convenience method to test whether the given DOM
Node node is a MathML element
having any localName. |
static boolean |
isMathMLElement(org.w3c.dom.Node node,
java.lang.String localName)
Convenience method to test whether the given DOM
Node node is a MathML element
having the given localName. |
static org.w3c.dom.Document |
isolateAnnotationXML(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
"Isolates" the XML annotation having the given encoding by producing a copy of the MathML
element with only the given annotation contents as children.
|
static org.w3c.dom.Document |
isolateAnnotationXML(UnwrappedParallelMathMLDOM unwrappedDOM,
java.lang.String encodingAttribute)
Version of
isolateAnnotationXML(Element, String) that works on an
UnwrappedParallelMathMLDOM. |
static org.w3c.dom.Document |
isolateFirstSemanticsBranch(org.w3c.dom.Element mathElement)
"Isolates" the first <semantics/> branch of an annotation MathML element
by producing a copy of the MathML element with a single child containing
only the first child of the <semantics/> element.
|
static org.w3c.dom.Document |
isolateFirstSemanticsBranch(UnwrappedParallelMathMLDOM unwrappedDOM)
Version of
isolateFirstSemanticsBranch(Element) that works on an
UnwrappedParallelMathMLDOM. |
static org.w3c.dom.Document |
parseMathMLDocumentString(java.lang.String mathmlDocument)
Convenience method that parses a MathML document specified as a UTF-8-encoded String.
|
static java.lang.String |
serializeDocument(org.w3c.dom.Document document)
Convenience method that serializes the given DOM Document as a String (encoded in UTF-8),
indenting the results and omitting the XML declaration, which is a reasonable way of
serializing a MathML document.
|
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
boolean indent,
boolean omitXMLDeclaration)
已过时。
Use one of the alternative methods, including
serializeDocument(Document, SerializationSpecifier) for ultimate control. |
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
SerializationSpecifier serializationOptions)
Convenience method that serializes the given DOM Document as a String, using the
specified
SerializationSpecifier, creating any XSLT stylesheet required for
serialization on an ad hoc basis. |
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
SerializationSpecifier serializationOptions,
StylesheetManager stylesheetManager)
Convenience method that serializes the given DOM Document as a String, using the
specified
SerializationSpecifier and given StylesheetManager to manage
any XSLT stylesheets required to serialize properly. |
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding)
Convenience method that serializes the given DOM Document as a String, using the
specified encoding, indenting the results and omitting the XML declaration,
which is a reasonable way of serializing a MathML document.
|
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding,
boolean indent)
Convenience method that serializes the given DOM Document as a String, using the
specified encoding and indentation options and omitting the XML declaration,
which is a reasonable way of serializing a MathML document.
|
static java.lang.String |
serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding,
boolean indent,
boolean omitXMLDeclaration)
已过时。
Use one of the alternative methods, including
serializeDocument(Document, SerializationSpecifier) for ultimate control. |
static java.lang.String |
serializeElement(org.w3c.dom.Element element)
Convenience method that serializes the given DOM Element as a String (encoded in UTF-8),
indenting the results and omitting the XML declaration, which is a reasonable way of
serializing MathML.
|
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
boolean indent)
Convenience method that serializes the given DOM Element as a String, indenting if
specified and omitting the XML declaration which is a reasonable way of serializing MathML.
|
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
boolean indent,
boolean omitXMLDeclaration)
已过时。
Use one of the alternative methods, including
serializeElement(Element, SerializationSpecifier) for ultimate control. |
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
SerializationSpecifier serializationOptions)
Convenience method that serializes the given DOM Element as a String, using the given
SerializationSpecifier, creating any XSLT stylesheet required for
serialization on an ad hoc basis. |
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
SerializationSpecifier serializationOptions,
StylesheetManager stylesheetManager)
Convenience method that serializes the given DOM Element as a String, using the given
SerializationSpecifier and given StylesheetManager to manage
any XSLT stylesheets required to serialize properly. |
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
java.lang.String encoding)
Convenience method that serializes the given DOM Element as a String, using
the given encoding, indenting the results and omitting the XML declaration,
which is a reasonable way of serializing MathML.
|
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
java.lang.String encoding,
boolean indent)
Convenience method that serializes the given DOM Element as a String, using
the given parameters.
|
static java.lang.String |
serializeElement(org.w3c.dom.Element element,
java.lang.String encoding,
boolean indent,
boolean omitXMLDeclaration)
|
static UnwrappedParallelMathMLDOM |
unwrapParallelMathMLDOM(org.w3c.dom.Element mathElement)
Convenience method to unwrap at MathML DOM Object containing top-level parallel markup,
as defined Section 5.3.1 of the MathML 2.0 specification.
|
public static final java.lang.String ANNOTATION_LOCAL_NAME
public static final java.lang.String ANNOTATION_XML_LOCAL_NAME
public static org.w3c.dom.Document parseMathMLDocumentString(java.lang.String mathmlDocument)
throws java.io.IOException,
org.xml.sax.SAXException
java.io.IOExceptionorg.xml.sax.SAXExceptionpublic static void convertMfencedToExplicitFences(org.w3c.dom.Document document)
mfenced element in the supplied document with
its explicit mrow/mo equivalent. The document is modified in place.public static void convertExplicitFencesToMfenced(org.w3c.dom.Document document)
mfenced. This exists for
compatibility with the legacy up-conversion stylesheets and modifies the document in place.public static java.lang.String serializeDocument(org.w3c.dom.Document document)
document - DOM document to serialize, must not be nullpublic static java.lang.String serializeDocument(org.w3c.dom.Document document,
SerializationSpecifier serializationOptions)
SerializationSpecifier, creating any XSLT stylesheet required for
serialization on an ad hoc basis.document - DOM document to serialize, must not be nullserializationOptions - desired SerializationOptions, may be null.public static java.lang.String serializeDocument(org.w3c.dom.Document document,
SerializationSpecifier serializationOptions,
StylesheetManager stylesheetManager)
SerializationSpecifier and given StylesheetManager to manage
any XSLT stylesheets required to serialize properly.document - DOM document to serialize, must not be nullserializationOptions - desired SerializationOptions, may be null.public static java.lang.String serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding)
document - DOM document to serialize, must not be nullencoding - desired encoding, null is interpreted as UTF-8.public static java.lang.String serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding,
boolean indent)
document - DOM document to serialize, must not be nullencoding - desired encoding, null is interpreted as UTF-8.@Deprecated
public static java.lang.String serializeDocument(org.w3c.dom.Document document,
boolean indent,
boolean omitXMLDeclaration)
serializeDocument(Document, SerializationSpecifier) for ultimate control.document - DOM element to serializeindent - whether to indent the results or notomitXMLDeclaration - whether to omit the XML declaration or not.@Deprecated
public static java.lang.String serializeDocument(org.w3c.dom.Document document,
java.lang.String encoding,
boolean indent,
boolean omitXMLDeclaration)
serializeDocument(Document, SerializationSpecifier) for ultimate control.document - DOM element to serializeencoding - desired encoding, null is interpreted as UTF-8.indent - whether to indent the results or notomitXMLDeclaration - whether to omit the XML declaration or not.public static java.lang.String serializeElement(org.w3c.dom.Element element)
element - DOM element to serialize, must not be null.public static java.lang.String serializeElement(org.w3c.dom.Element element,
SerializationSpecifier serializationOptions)
SerializationSpecifier, creating any XSLT stylesheet required for
serialization on an ad hoc basis.element - DOM element to serialize, must not be null.serializationOptions - SerializationSpecifier, may be null.public static java.lang.String serializeElement(org.w3c.dom.Element element,
SerializationSpecifier serializationOptions,
StylesheetManager stylesheetManager)
SerializationSpecifier and given StylesheetManager to manage
any XSLT stylesheets required to serialize properly.element - DOM element to serialize, must not be null.serializationOptions - SerializationSpecifier, may be null.stylesheetManager - StylesheetManager, must not be nullpublic static java.lang.String serializeElement(org.w3c.dom.Element element,
java.lang.String encoding)
element - DOM element to serializeencoding - desired encoding, null is interpreted as UTF-8.public static java.lang.String serializeElement(org.w3c.dom.Element element,
boolean indent)
element - DOM element to serializeindent - whether to indent or not@Deprecated
public static java.lang.String serializeElement(org.w3c.dom.Element element,
boolean indent,
boolean omitXMLDeclaration)
serializeElement(Element, SerializationSpecifier) for ultimate control.element - DOM element to serializeindent - whether to indent the results or notomitXMLDeclaration - whether to omit the XML declaration or not.@Deprecated
public static java.lang.String serializeElement(org.w3c.dom.Element element,
java.lang.String encoding,
boolean indent,
boolean omitXMLDeclaration)
serializeElement(Element, SerializationSpecifier) or
serializeElement(Element, SerializationSpecifier, StylesheetManager)element - DOM element to serializeencoding - desired encoding, null is interpreted as UTF-8.indent - whether to indent the results or notomitXMLDeclaration - whether to omit the XML declaration or not.public static java.lang.String serializeElement(org.w3c.dom.Element element,
java.lang.String encoding,
boolean indent)
(This can be used in more general cases than MathML, through experienced programmers may want more control over what happens here.)
element - DOM element to serializeencoding - desired encoding, null is interpreted as UTF-8.indent - whether to indent the results or notpublic static boolean isMathMLElement(org.w3c.dom.Node node)
Node node is a MathML element
having any localName.node - Node to testjava.lang.IllegalArgumentException - if node is null.public static boolean isMathMLElement(org.w3c.dom.Node node,
java.lang.String localName)
Node node is a MathML element
having the given localName.node - Node to testlocalName - MathML local name to test for, such as mi or math,
or null to indicate "any name in the MathML namespace".java.lang.IllegalArgumentException - if node is null.public static void ensureMathMLContainer(org.w3c.dom.Element mathElement)
public static org.w3c.dom.Element ensureMathMLDocument(org.w3c.dom.Document document)
Document contains a single MathML math
Element. If so, the Element is returned. Otherwise, an IllegalArgumentException is
thrown.public static UnwrappedParallelMathMLDOM unwrapParallelMathMLDOM(org.w3c.dom.Element mathElement)
If there is no parallel markup detected then null if returned.
If the given element is null or is not a MathML "math" element, then an IllegalArgumentException
is thrown.
public static org.w3c.dom.Element extractFirstSemanticsBranch(org.w3c.dom.Element mathElement)
public static java.lang.String extractAnnotationString(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
math element, if such an annotation is found.
This assumes the following structure:
<math>
<semantics>
...
<annotation encoding="...">text</annotation>
</semantics>
</math>
mathElement - public static org.w3c.dom.NodeList extractAnnotationXML(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
math element, if such an annotation is found.
This assumes the following structure:
<math>
<semantics>
...
<annotation-xml encoding="...">XML annotation</annotation>
</semantics>
</math>
mathElement - annotation-xml element, or null if no such annotation found.public static org.w3c.dom.Document isolateFirstSemanticsBranch(org.w3c.dom.Element mathElement)
For example:
<math>
<semantics>
<mi>x</mi>
<annotation-xml encoding='blah'><x/></annotation-xml>
</semantics>
</math>
results in:
<math>
<mi>x</mi>
</math>
math
element is not annotated.java.lang.IllegalArgumentException - if passed null or the given element is not a
math element.public static org.w3c.dom.Document isolateFirstSemanticsBranch(UnwrappedParallelMathMLDOM unwrappedDOM)
isolateFirstSemanticsBranch(Element) that works on an
UnwrappedParallelMathMLDOM.java.lang.IllegalArgumentException - if passed null.public static org.w3c.dom.Document isolateAnnotationXML(org.w3c.dom.Element mathElement,
java.lang.String encodingAttribute)
For example:
<math>
<semantics>
<mi>x</mi>
<annotation-xml encoding='blah'><x/></annotation-xml>
</semantics>
</math>
results in:
<math>
<x/>
</math>
math
element is not annotated or does not have the required annotation.java.lang.IllegalArgumentException - if passed null or the given element is not a
math element.public static org.w3c.dom.Document isolateAnnotationXML(UnwrappedParallelMathMLDOM unwrappedDOM, java.lang.String encodingAttribute)
isolateAnnotationXML(Element, String) that works on an
UnwrappedParallelMathMLDOM.java.lang.IllegalArgumentException - if passed null.