public final class StylesheetManager
extends java.lang.Object
StylesheetCache to cache stylesheets for performance.
This has been made "public" as it is used by certain standalone tools, like the
MathMLDownConverter, but its use outside SnuggleTeX is perhaps somewhat limited.
This class is thread-safe.
| 构造器和说明 |
|---|
StylesheetManager()
|
StylesheetManager(StylesheetCache cache)
Creates a new
StylesheetManager using the DefaultTransformerFactoryChooser and
the given StylesheetCache. |
StylesheetManager(TransformerFactoryChooser transformerFactoryChooser,
StylesheetCache cache)
|
| 限定符和类型 | 方法和说明 |
|---|---|
javax.xml.transform.Templates |
getCompiledStylesheet(java.lang.String classPathUri)
Obtains the XSLT stylesheet at the given ClassPathURI, using the
StylesheetCache
(if set) to cache stylesheets for efficiency. |
javax.xml.transform.Templates |
getCompiledStylesheet(java.lang.String classPathUri,
boolean requireXSLT20)
Obtains the XSLT stylesheet at the given ClassPathURI, using the
StylesheetCache
(if set) to cache stylesheets for efficiency. |
javax.xml.transform.Templates |
getCompiledStylesheetDriver(java.util.List<java.lang.String> importClassPathUris,
boolean requireXSLT20)
Obtains a "driver" XSLT stylesheet that imports the stylesheets having the given
ClassPath URIs, using the
StylesheetCache (if set) to cache the resulting driver for efficiency. |
javax.xml.transform.Transformer |
getSerializer(java.lang.String serializerUri,
SerializationSpecifier serializationOptions)
Obtains a serializer stylesheet based on the stylesheet at the given URI, configured
as per the given
SerializationSpecifier. |
StylesheetCache |
getStylesheetCache()
Returns the current
StylesheetCache for this manager, which may be null. |
javax.xml.transform.TransformerFactory |
getTransformerFactory(boolean requireXSLT20)
Uses the current
TransformerFactoryChooser to obtain a TransformerFactory
suitable for either XSLT 1.0 or XSLT 2.0 (as specified), and configured to use a
ClassPathURIResolver to make it easy to find internal stylesheets. |
TransformerFactoryChooser |
getTransformerFactoryChooser()
Returns the current
TransformerFactoryChooser for this StylesheetManager, which is
used to initialise TransformerFactory instances. |
void |
setStylesheetCache(StylesheetCache stylesheetCache)
Sets the
StylesheetCache for this manager, which may be null to indicate that
no caching should take place. |
void |
setTransformerFactoryChooser(TransformerFactoryChooser transformerFactoryChooser)
Sets the
TransformerFactoryChooser for this StylesheetManager, which is
used to initialise TransformerFactory instances. |
boolean |
supportsXSLT20()
Returns whether or not XSLT 2.0 is supported, by asking the underlying
TransformerFactoryChooser. |
public StylesheetManager()
public StylesheetManager(StylesheetCache cache)
StylesheetManager using the DefaultTransformerFactoryChooser and
the given StylesheetCache.cache - StylesheetCache to use, which may be null if you don't want to do any
caching.public StylesheetManager(TransformerFactoryChooser transformerFactoryChooser, StylesheetCache cache)
transformerFactoryChooser - TransformerFactoryChooser to use, which must not
be null.public TransformerFactoryChooser getTransformerFactoryChooser()
TransformerFactoryChooser for this StylesheetManager, which is
used to initialise TransformerFactory instances. This is never null.public void setTransformerFactoryChooser(TransformerFactoryChooser transformerFactoryChooser)
TransformerFactoryChooser for this StylesheetManager, which is
used to initialise TransformerFactory instances.transformerFactoryChooser - new TransformerFactoryChooser, which must not be null.public StylesheetCache getStylesheetCache()
StylesheetCache for this manager, which may be null.public void setStylesheetCache(StylesheetCache stylesheetCache)
StylesheetCache for this manager, which may be null to indicate that
no caching should take place.public javax.xml.transform.TransformerFactory getTransformerFactory(boolean requireXSLT20)
TransformerFactoryChooser to obtain a TransformerFactory
suitable for either XSLT 1.0 or XSLT 2.0 (as specified), and configured to use a
ClassPathURIResolver to make it easy to find internal stylesheets.public boolean supportsXSLT20()
TransformerFactoryChooser.public javax.xml.transform.Templates getCompiledStylesheet(java.lang.String classPathUri)
StylesheetCache
(if set) to cache stylesheets for efficiency.classPathUri - location of the XSLT stylesheet in the ClassPath, following the
URI scheme in ClassPathURIResolver.public javax.xml.transform.Templates getCompiledStylesheet(java.lang.String classPathUri,
boolean requireXSLT20)
StylesheetCache
(if set) to cache stylesheets for efficiency.classPathUri - location of the XSLT stylesheet in the ClassPath, following the
URI scheme in ClassPathURIResolver.requireXSLT20 - if false uses the JAXP default TransformerFactory, otherwise
specifies that we require an XSLT 2.0-compliant transformer, of which the only currently
supported implementation is SAXON 9.x.public javax.xml.transform.Templates getCompiledStylesheetDriver(java.util.List<java.lang.String> importClassPathUris,
boolean requireXSLT20)
StylesheetCache (if set) to cache the resulting driver for efficiency.importClassPathUris - List of locations of the XSLT stylesheets to be compiled, following the
URI scheme in ClassPathURIResolver.requireXSLT20 - if false uses the JAXP default TransformerFactory, otherwise
specifies that we require an XSLT 2.0-compliant transformer, of which the only currently
supported implementation is SAXON 9.x.public javax.xml.transform.Transformer getSerializer(java.lang.String serializerUri,
SerializationSpecifier serializationOptions)
SerializationSpecifier. (Some options may require XSLT 2.0 support.)serializerUri - URI for the required serializing stylesheet, null for the default
serializer.serializationOptions - desired SerializationSpecifier, null for default optionsSnuggleRuntimeException - if the serializer could not be created, or if an XSLT 2.0 processor
was required but could not be obtained.