Class MCRXSLTransformer
java.lang.Object
org.mycore.common.content.transformer.MCRContentTransformer
org.mycore.common.content.transformer.MCRParameterizedTransformer
org.mycore.common.content.transformer.MCRXSLTransformer
- Direct Known Subclasses:
MCRXSL2JAXBTransformer
,MCRXSL2XMLTransformer
Transforms XML content using a static XSL stylesheet. The stylesheet is configured via
MCR.ContentTransformer.{ID}.Stylesheet
. You may choose your own instance of
SAXTransformerFactory
via MCR.ContentTransformer.{ID}.TransformerFactoryClass
.
The default transformer factory implementation TransformerFactoryImpl
is configured with MCR.LayoutService.TransformerFactoryClass
.- Author:
- Frank Lützenkirchen
-
Field Summary
Modifier and TypeFieldDescriptionprotected long[]
protected long
protected Templates[]
protected MCRTemplatesSource[]
The compiled XSL stylesheetprotected SAXTransformerFactory
Fields inherited from class org.mycore.common.content.transformer.MCRContentTransformer
contentDisposition, DEFAULT_CONTENT_DISPOSITION, fileExtension, mimeType
-
Constructor Summary
ConstructorDescriptionMCRXSLTransformer
(Class<? extends TransformerFactory> tfClass) MCRXSLTransformer
(String... stylesheets) -
Method Summary
Modifier and TypeMethodDescriptionReturns the encoding of characters in the binary stream.Returns the file extension that is usually related to the transformed content.static MCRXSLTransformer
getInstance
(Class<? extends TransformerFactory> tfClass, String... stylesheets) static MCRXSLTransformer
getInstance
(String... stylesheets) Returns the MIME type of the transformed content, may return the default mime typeprotected MCRContent
getTransformedContent
(MCRContent source, XMLReader reader, TransformerHandler transformerHandler) protected LinkedList<TransformerHandler>
getTransformHandlerList
(MCRParameterCollector parameterCollector) protected XMLReader
getXMLReader
(LinkedList<TransformerHandler> transformHandlerList) void
Called by the factory to initialize configuration of this transformervoid
setStylesheets
(String... stylesheets) void
setTransformerFactory
(String factoryClass) transform
(MCRContent source) Transforms MCRContent.void
transform
(MCRContent source, OutputStream out) void
transform
(MCRContent source, OutputStream out, MCRParameterCollector parameter) transform
(MCRContent source, MCRParameterCollector parameter) Transforms MCRContent.protected MCRContent
transform
(MCRContent source, XMLReader reader, TransformerHandler transformerHandler, MCRParameterCollector parameter) Methods inherited from class org.mycore.common.content.transformer.MCRContentTransformer
getContentDisposition, getDefaultExtension, getDefaultMimeType
-
Field Details
-
templateSources
The compiled XSL stylesheet -
templates
-
modified
protected long[] modified -
modifiedChecked
protected long modifiedChecked -
tFactory
-
-
Constructor Details
-
MCRXSLTransformer
-
MCRXSLTransformer
public MCRXSLTransformer() -
MCRXSLTransformer
-
-
Method Details
-
setTransformerFactory
-
getInstance
-
getInstance
public static MCRXSLTransformer getInstance(Class<? extends TransformerFactory> tfClass, String... stylesheets) -
init
Description copied from class:MCRContentTransformer
Called by the factory to initialize configuration of this transformer- Overrides:
init
in classMCRContentTransformer
-
setStylesheets
-
getEncoding
Description copied from class:MCRContentTransformer
Returns the encoding of characters in the binary stream. Will return null if the encoding is unknown or the results does not represent character data.- Overrides:
getEncoding
in classMCRContentTransformer
- Throws:
TransformerException
SAXException
ParserConfigurationException
-
getMimeType
Description copied from class:MCRContentTransformer
Returns the MIME type of the transformed content, may return the default mime type- Overrides:
getMimeType
in classMCRContentTransformer
- Throws:
TransformerException
SAXException
ParserConfigurationException
-
transform
Description copied from class:MCRContentTransformer
Transforms MCRContent. Subclasses implement different transformation methods- Specified by:
transform
in classMCRContentTransformer
- Throws:
IOException
-
transform
Description copied from class:MCRParameterizedTransformer
Transforms MCRContent. Subclasses implement different transformation methods- Specified by:
transform
in classMCRParameterizedTransformer
- Throws:
IOException
-
transform
- Overrides:
transform
in classMCRContentTransformer
- Throws:
IOException
-
transform
public void transform(MCRContent source, OutputStream out, MCRParameterCollector parameter) throws IOException - Overrides:
transform
in classMCRParameterizedTransformer
- Throws:
IOException
-
transform
protected MCRContent transform(MCRContent source, XMLReader reader, TransformerHandler transformerHandler, MCRParameterCollector parameter) throws IOException, SAXException, TransformerException, ParserConfigurationException -
getTransformedContent
protected MCRContent getTransformedContent(MCRContent source, XMLReader reader, TransformerHandler transformerHandler) throws IOException, SAXException - Throws:
IOException
SAXException
-
getTransformHandlerList
protected LinkedList<TransformerHandler> getTransformHandlerList(MCRParameterCollector parameterCollector) throws TransformerConfigurationException, SAXException, ParserConfigurationException -
getXMLReader
protected XMLReader getXMLReader(LinkedList<TransformerHandler> transformHandlerList) throws SAXException, ParserConfigurationException -
getOutputProperties
public Properties getOutputProperties() throws TransformerConfigurationException, SAXException, ParserConfigurationException -
getFileExtension
public String getFileExtension() throws TransformerException, SAXException, ParserConfigurationExceptionDescription copied from class:MCRContentTransformer
Returns the file extension that is usually related to the transformed content.- Overrides:
getFileExtension
in classMCRContentTransformer
- Throws:
TransformerException
SAXException
ParserConfigurationException
-