Package org.openehealth.ipf.commons.xml
Class XsltTransmogrifier<T>
java.lang.Object
org.openehealth.ipf.commons.xml.AbstractCachingXmlProcessor<Templates>
org.openehealth.ipf.commons.xml.XsltTransmogrifier<T>
- All Implemented Interfaces:
Transmogrifier<Source,T>
- Direct Known Subclasses:
SchematronTransmogrifier
public class XsltTransmogrifier<T>
extends AbstractCachingXmlProcessor<Templates>
implements Transmogrifier<Source,T>
Xslt Processor transforming a
Source into an object of type T. The stylesheet to be used is passed with the
zap(Source, Object...) call, however, the Xslt Template object is cached for subsequent transformations
using this stylesheet.
Xslt parameters can be passed in as Map parameter.
Note: This class is thread-safe and reentrant.
- Author:
- Christian Ohr
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openehealth.ipf.commons.xml.AbstractCachingXmlProcessor
AbstractCachingXmlProcessor.Loader<S> -
Field Summary
Fields inherited from class org.openehealth.ipf.commons.xml.AbstractCachingXmlProcessor
RESOURCE_LOCATION -
Constructor Summary
ConstructorsConstructorDescriptionXsltTransmogrifier(Class<T> outputFormat) XsltTransmogrifier(Class<T> outputFormat, ClassLoader classLoader) XsltTransmogrifier(Class<T> outputFormat, ClassLoader classLoader, Map<String, Object> staticParams) -
Method Summary
Modifier and TypeMethodDescriptionprotected TemplatescreateResource(Object... params) Creates a ready-to-use resource (e.g. an XML Schema instance) for the given key.getCache()voidsetStaticParams(Map<String, Object> staticParams) protected voidsetXsltParameters(Transformer transformer, Map<String, Object> param) Sets the parameter to theTransformerobjectConverts a Source into a Result using a XSL processor.Methods inherited from class org.openehealth.ipf.commons.xml.AbstractCachingXmlProcessor
resource, resourceCacheKey, resourceContent, resourceLocation, resourceParameters
-
Constructor Details
-
XsltTransmogrifier
public XsltTransmogrifier() -
XsltTransmogrifier
-
XsltTransmogrifier
-
XsltTransmogrifier
-
XsltTransmogrifier
public XsltTransmogrifier(Class<T> outputFormat, ClassLoader classLoader, Map<String, Object> staticParams) - Parameters:
outputFormat- currently supported: String, Writer, OutputStreamclassLoader- class loader for resource retrieval, may benullstaticParams- static Xslt parameters
-
-
Method Details
-
getFactory
-
getCache
- Specified by:
getCachein classAbstractCachingXmlProcessor<Templates>- Returns:
- static cache for the configured resource type. Note that the returned Map is not necessarily synchronized.
-
zap
Converts a Source into a Result using a XSL processor.The XSL stylesheet resource location is mandatory in the first extra parameter. XSL Parameters may be passed as a Map in the second parameter.
- Specified by:
zapin interfaceTransmogrifier<Source,T> - Parameters:
source- what goes inparams- parameters- Returns:
- what comes out
- See Also:
-
setXsltParameters
Sets the parameter to theTransformerobject -
createResource
Description copied from class:AbstractCachingXmlProcessorCreates a ready-to-use resource (e.g. an XML Schema instance) for the given key. Insertion into the cache will happen externally, this method's purpose is only to instantiate the resource to be cached. This method does not need to be re-entrant, but its result MUST be thread-safe.- Specified by:
createResourcein classAbstractCachingXmlProcessor<Templates>- Parameters:
params- validator/transmogrifier parameters.- Returns:
- resource of the configured type.
-
getStaticParams
-
setStaticParams
-