org.intuitel.merger
public abstract class XSLTSerializer extends Serializer
This class was just included to reuse code in those cases in which a XSLT stylesheet is used for the transformation. In those cases, most of the code is written here, while the Subclasses set the value of specific parameters.
The use of XSLTSerializer asumes the following conditions for the transformation:
With such asumptions, this class provides the marshall and unmarshall methods while the extending classes should provide the XSLT transformation files.
Constructor and Description |
---|
XSLTSerializer() |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getCCMXSLT()
Returns the path to the XSLT stylesheet file that will be used to generate the CCM.
|
protected abstract String |
getCMXSLT()
Returns the path to the XSLT stylesheet file that will be used to generate the CM.
|
protected abstract String |
getExternalFormatName()
Returns the name of the external format produced by the XSLTSerializer.
|
protected abstract String |
getToExternalFormatXSLT()
Returns the path to the XSLT stylesheet file that will be used to produce the external format.
|
void |
marshall(SLOM theSlom,
Iterator<OutputStream> it)
Writes the information stored in a SLOM object in a OutputStream.
|
protected static void |
mergeCMandCCM(InputStream stylesheet,
InputStream input,
OutputStream output,
String intuiCMLocation,
String intuiCCMLocation)
Merges two XML files containing CM and CCM into a single file.
|
protected static void |
transformFile(InputStream stylesheet,
InputStream input,
OutputStream output)
Transforms a XML file acording to the rules provided by a XSLT stylesheet.
|
SLOM |
unmarshall(Set<File> inputCourse)
Reads content from a file and returns a SLOM object with the information read.
|
protected abstract String getCCMXSLT()
This method, implemented in the subclasses, returns a String with the path of the XSLT file that will be used to transform from the input format to build the CCM file.
In the current implementation, this method is used by unmarshall and marshall methods. The returned path refers to the location of the XSLT file in the jar package of the library.
protected abstract String getCMXSLT()
This method, implemented in the subclasses, returns a String with the path of the XSLT file that will be used to transform from the input format to build the CM file.
In the current implementation, this method is used by unmarshall and marshall methods. The returned path refers to the location of the XSLT file in the jar package of the library.
protected abstract String getToExternalFormatXSLT()
This method, implemented in the subclasses, returns a String with the path of the XSLT file that will be used to transform a SLOM file to the selected external format.
In the current implementation, this method is used by unmarshall and marshall methods. The returned path refers to the location of the XSLT file in the jar package of the library.
protected abstract String getExternalFormatName()
This method, implemented in the subclasses, returns a String with the name of the external format to be produced.
In the current implementation, this method is used by unmarshall and marshall methods.
public SLOM unmarshall(Set<File> inputCourse) throws BadFileException, IOException
Serializer
The unmarshall method reads content from a file and returns a SLOM object with the information read.
The method accepts a Set of File objects, but in most cases the Set will only contain a single File. This is to support those cases in which the information require several files to be complete.
Currently supported input formats are SCORM, SLOM, IMSLD and Semantic Media Wiki
unmarshall
in class Serializer
inputCourse
- A Set of files containing the course information in the desired formatBadFileException
IOException
protected static void transformFile(InputStream stylesheet, InputStream input, OutputStream output)
This method is internally used by the marshall and unmarshall methods, but has been set as protected (instead of private) to allow developers who want to extend thi class to reuse the provided functionality.
stylesheet
- The XSLT to apply in the transformationinput
- The XML file to transformoutput
- An OutputStream to write the result of the transformationmarshall(org.intuitel.slom.SLOM, java.util.Iterator)
,
unmarshall(java.util.Set)
protected static void mergeCMandCCM(InputStream stylesheet, InputStream input, OutputStream output, String intuiCMLocation, String intuiCCMLocation)
This method is internally used by the marshall method, in order to execute the transformation to the external format taking a single file as input source. It has been set as protected (instead of private) to allow developers who want to extend thi class to reuse the provided functionality.
stylesheet
- The XSLT that actually mergers the filesinput
- The CM contentintuiCMLocation
- the path to the CM file in the local file systemintuiCCMLocation
- the path to the CCM file in the local file systemoutput
- An OutputStream to write the result of the mergemarshall(org.intuitel.slom.SLOM, java.util.Iterator)
public void marshall(SLOM theSlom, Iterator<OutputStream> it) throws InvalidParameterException, IOException
Serializer
The marshall method serializes a SLOM object using the serialization supported by the subclass of Serializer that is being used.
The method accepts the SLOM object to be serialized, and a Iterator of OutputStream objects. In the case of IMSLD and SCORM, for instance, only one OutputStream is required since all the information fits in the imsmanifest.xml file. In the case of SLOM, two OutputStream are required, to store the CM and the CCM respectively.
The method returns nothing, since the generated information is written in the OutputStream objects passed as parameter.
Currently supported input formats are SCORM, SLOM and IMSLD. Marshalling is not supported for Semantic Media Wiki
marshall
in class Serializer
theSlom
- A SLOM object containing the information to be serializedit
- A Iterator of OutputStream objects, that will be used to write the serializationInvalidParameterException
IOException
Copyright © 2014. All rights reserved.