Top Description Fields Constructors Methods
uk.ac.ed.ph.snuggletex.upconversion

public Class MathMLUpConverter

extends Object
Class Inheritance
Imports
org.w3c.dom.Document, .Element, org.xml.sax.InputSource, .SAXException, uk.ac.ed.ph.snuggletex.*, uk.ac.ed.ph.snuggletex.internal.util.XMLUtilities, uk.ac.ed.ph.snuggletex.utilities.*, javax.xml.transform.Templates, .Transformer, .TransformerConfigurationException, .TransformerException, javax.xml.transform.dom.DOMResult, .DOMSource, java.io.IOException, .StringReader

Standalone utility class for "up-converting" MathML Documents created by either SnuggleTeX or ASCIIMathML as follows: This can be invoked within the normal SnuggleTeX parsing process using by adding a UpConvertingPostProcessor to the List returned by DOMOutputOptions#getDOMPostProcessors().

Usage Notes

Author
David McKain
Since
1.1.0
Version
$Revision$

Field Summary

Modifier and TypeField and Description
private static final String
ASCIIMATH_FIXER_XSL_LOCATION

Location of the initial XSLT for fixing up ASCIIMathML

public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private final StylesheetManager
stylesheetManager

Helper to manage the StylesheetCache

private static final String
UPCONVERTER_BASE_LOCATION

"Base" location for the XSLT stylesheets used here

private static final String
UPCONVERTER_XSL_LOCATION

Location of the main up-converting XSLT

Constructor Summary

AccessConstructor and Description
public
MathMLUpConverter()

Creates a new up-converter using a simple internal cache, hard-coded to use Saxon for XSLT 2.0 support.

public
MathMLUpConverter(StylesheetCache stylesheetCache)

Creates a new up-converter using the given StylesheetCache to cache internal XSLT stylesheets, hard-coded to use Saxon for XSLT 2.0 support.

public
MathMLUpConverter(final TransformerFactoryChooser
TransformerFactoryChooser to use, which must not be null.
transformerFactoryChooser
,
StylesheetCache
StylesheetCache to use, which may be null to avoid caching.
stylesheetCache
)

Creates a new up-converter using the given TransformerFactoryChooser and StylesheetCache to cache internal XSLT stylesheets.

public
MathMLUpConverter(StylesheetManager stylesheetManager)

Creates a new up-converter using the given StylesheetManager for managing XSLT stylesheets and stuff.

Method Summary

Modifier and TypeMethod and Description
private Element
createUpConversionOptionsElement(final UpConversionOptions upConversionOptions)

DEVELOPER NOTE: I have included the default value for this parameter within the XSLT as well so that people can reuse it easier in a standalone fashion.

public Document
upConvertASCIIMathML(final Document
DOM Document, assumed to have been generated by ASCIIMathML
asciiMathMLDocument
,
final UpConversionOptions
UpConversionOptions to use, or null to use defaults.
upConversionOptions
)

Up-converts the ASCIIMathML output represented by the given Document.

public Document
upConvertASCIIMathML(final String
ASCIIMathML output string
rawASCIIMathML
,
final UpConversionOptions
UpConversionOptions to use, or null to use defaults.
upConversionOptions
)

Convenience version of upConvertASCIIMathML(Document, UpConversionOptions) that takes the raw ASCIIMathML as a String.

public Document
upConvertSnuggleTeXMathML(final Document
DOM Document, assumed to have been generated by SnuggleSession#buildDOMSubtree() or similar.
document
,
final UpConversionOptions
UpConversionOptions to use, or null to use defaults.
upConversionOptions
)

Up-converts the SnuggleTeX XHTML output Document (assumed to contain islands of MathML), creating a new result Document.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASCIIMATH_FIXER_XSL_LOCATIONback to summary
private static final String ASCIIMATH_FIXER_XSL_LOCATION

Location of the initial XSLT for fixing up ASCIIMathML

ASCIIMATH_INPUT_ANNOTATION_NAMEback to summary
public static final String ASCIIMATH_INPUT_ANNOTATION_NAME
BRACKETED_PRESENTATION_MATHML_ANNOTATION_NAMEback to summary
public static final String BRACKETED_PRESENTATION_MATHML_ANNOTATION_NAME
CONTENT_FAILURES_ANNOTATION_NAMEback to summary
public static final String CONTENT_FAILURES_ANNOTATION_NAME
CONTENT_MATHML_ANNOTATION_NAMEback to summary
public static final String CONTENT_MATHML_ANNOTATION_NAME
LATEX_ANNOTATION_NAMEback to summary
public static final String LATEX_ANNOTATION_NAME
MAXIMA_ANNOTATION_NAMEback to summary
public static final String MAXIMA_ANNOTATION_NAME
MAXIMA_FAILURES_ANNOTATION_NAMEback to summary
public static final String MAXIMA_FAILURES_ANNOTATION_NAME
SNUGGLETEX_ANNOTATION_NAMEback to summary
public static final String SNUGGLETEX_ANNOTATION_NAME
stylesheetManagerback to summary
private final StylesheetManager stylesheetManager

Helper to manage the StylesheetCache

UPCONVERTER_BASE_LOCATIONback to summary
private static final String UPCONVERTER_BASE_LOCATION

"Base" location for the XSLT stylesheets used here

UPCONVERTER_XSL_LOCATIONback to summary
private static final String UPCONVERTER_XSL_LOCATION

Location of the main up-converting XSLT

Constructor Detail

MathMLUpConverterback to summary
public MathMLUpConverter()

Creates a new up-converter using a simple internal cache, hard-coded to use Saxon for XSLT 2.0 support.

Use this constructor if you don't use XSLT yourself. In this case, you'll want your instance of this class to be reused as much as possible to get the benefits of caching.

MathMLUpConverterback to summary
public MathMLUpConverter(StylesheetCache stylesheetCache)

Creates a new up-converter using the given StylesheetCache to cache internal XSLT stylesheets, hard-coded to use Saxon for XSLT 2.0 support.

Use this constructor if you do your own XSLT caching that you want to integrate in, or if the default doesn't do what you want.

MathMLUpConverterback to summary
public MathMLUpConverter(final TransformerFactoryChooser transformerFactoryChooser, StylesheetCache stylesheetCache)

Creates a new up-converter using the given TransformerFactoryChooser and StylesheetCache to cache internal XSLT stylesheets.

Use this constructor if you do your own XSLT caching that you want to integrate in, or if the default doesn't do what you want and/or if you want to override the choice of Saxon for XSLT 2.0 support (which is currently a bad idea!)

Parameters
transformerFactoryChooser:TransformerFactoryChooser

TransformerFactoryChooser to use, which must not be null.

stylesheetCache:StylesheetCache

StylesheetCache to use, which may be null to avoid caching.

MathMLUpConverterback to summary
public MathMLUpConverter(StylesheetManager stylesheetManager)

Creates a new up-converter using the given StylesheetManager for managing XSLT stylesheets and stuff.

Method Detail

createUpConversionOptionsElementback to summary
private Element createUpConversionOptionsElement(final UpConversionOptions upConversionOptions)

DEVELOPER NOTE: I have included the default value for this parameter within the XSLT as well so that people can reuse it easier in a standalone fashion. Make sure you update the XSLT if any of the defaults change here.

upConvertASCIIMathMLback to summary
public Document upConvertASCIIMathML(final Document asciiMathMLDocument, final UpConversionOptions upConversionOptions)

Up-converts the ASCIIMathML output represented by the given Document. This would normally consist of a single MathML element, but can be arbitrary XML containing MathML islands.

Parameters
asciiMathMLDocument:Document

DOM Document, assumed to have been generated by ASCIIMathML

upConversionOptions:UpConversionOptions

UpConversionOptions to use, or null to use defaults.

upConvertASCIIMathMLback to summary
public Document upConvertASCIIMathML(final String rawASCIIMathML, final UpConversionOptions upConversionOptions)

Convenience version of upConvertASCIIMathML(Document, UpConversionOptions) that takes the raw ASCIIMathML as a String. You would normally extract this from ASCIIMathML using some of our JavaScript helper functions.

Parameters
rawASCIIMathML:String

ASCIIMathML output string

upConversionOptions:UpConversionOptions

UpConversionOptions to use, or null to use defaults.

upConvertSnuggleTeXMathMLback to summary
public Document upConvertSnuggleTeXMathML(final Document document, final UpConversionOptions upConversionOptions)

Up-converts the SnuggleTeX XHTML output Document (assumed to contain islands of MathML), creating a new result Document.

Parameters
document:Document

DOM Document, assumed to have been generated by SnuggleSession#buildDOMSubtree() or similar.

upConversionOptions:UpConversionOptions

UpConversionOptions to use, or null to use defaults.