|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.uniba.euromath.gene.XsltExporterBase
public class XsltExporterBase
Serves as the base class for XSLT exporters. It does not handle
emp:mark
elements specially. No properties are defined. The
stylesheet obtains all parameters from the EuroMath as normal stylesheet
does.
Field Summary | |
---|---|
protected ExportHelper |
helper
Helper object for exporter. |
protected ExporterInfo |
info
Info object. |
static String |
PARAMETER_DOCUMENT_DIR
Denotes a string representing directory where the document is stored. |
static String |
PARAMETER_DOCUMENT_EXTENSION
Denotes a string representing the extension of the document being transformed. |
static String |
PARAMETER_DOCUMENT_NAME
Denotes a string representing the name of the document being translated. |
static String |
PARAMETER_EUROMATH_IDSTRING
Denotes a string identificating the EuroMath instance. |
static String |
PARAMETER_IS_ROOT
Determines whether the stylesheet is processing the root nametree - the nametree that contains root element of the document. |
static String |
PARAMETER_NAMESPACE
The namespace of all parameters given to the stylesheet. |
static String |
PARAMETER_PARENT_NAMESPACE
If this nametree is not root then this parameter contains namespace of the parent nametree, otherwise it is not defined. |
static String |
PARAMETER_PROCESSING_SOURCE
If true then we are transforming source document. |
static String |
PARAMETER_RESULT_DIR
Denotes a string representing directory where the result document. |
static String |
PARAMETER_RESULT_EXTENSION
Denotes a string representing the extension of the document being transformed. |
static String |
PARAMETER_RESULT_NAME
Denotes a string representing the name of the output file that has been given as a parameter to the transformer. |
protected Transformer |
transformer
The XSLT transformer instance. |
Constructor Summary | |
---|---|
XsltExporterBase(ExportHelper helper,
String xsltUri,
ExporterInfo info)
The constructor. |
|
XsltExporterBase(ExportHelper helper,
Transformer transformer,
ExporterInfo info)
The constructor. |
Method Summary | |
---|---|
void |
export(Source source,
Result result,
ExportContext context)
Exports (transforms) the document from a single namespace and writes it to the result. |
protected static void |
fillParameters(Transformer transformer,
ExportContext context)
Fills the transformer with all neccesary parameters. |
ExporterInfo |
getInfo()
Returns information about the exporter. |
Map<String,Object> |
getProperties()
Properties that drives the export process. |
static XsltExporterBase |
newFromConfig(ExportHelper helper,
sk.uniba.euromath.config.bind.StylesheetType xslt,
ExporterInfo info)
Constructs exporter from given config item. |
static XsltExporterBase |
newIdentity(ExportHelper helper,
ExporterInfo info)
Constructs identity exporter. |
Object |
offerObject()
When the exporter accepts the ObjectSource but wants to provide an object as a result to the exporter E (for example it wants E to draw something on a certain instance of Graphics), then return non- null
value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Transformer transformer
protected final ExportHelper helper
protected final ExporterInfo info
public static final String PARAMETER_NAMESPACE
public static final String PARAMETER_IS_ROOT
public static final String PARAMETER_DOCUMENT_NAME
public static final String PARAMETER_DOCUMENT_EXTENSION
public static final String PARAMETER_DOCUMENT_DIR
public static final String PARAMETER_RESULT_NAME
public static final String PARAMETER_RESULT_EXTENSION
public static final String PARAMETER_RESULT_DIR
public static final String PARAMETER_EUROMATH_IDSTRING
EuroMath2-1.1.9
". String value.
public static final String PARAMETER_PARENT_NAMESPACE
public static final String PARAMETER_PROCESSING_SOURCE
true
then we are transforming source document. If
false
then we are processing an output of some exporter.
Constructor Detail |
---|
public XsltExporterBase(ExportHelper helper, String xsltUri, ExporterInfo info) throws ExportException
helper
- the helper object.xsltUri
- location of the xslt script, relative to the plugin root.info
- info object about this exporter. It must not support object
input nor output.
ExportException
- if object initialization fails.public XsltExporterBase(ExportHelper helper, Transformer transformer, ExporterInfo info)
helper
- the helper object.transformer
- the transformer instance.info
- information about this exporter. It must not support object
input nor output.Method Detail |
---|
public static XsltExporterBase newIdentity(ExportHelper helper, ExporterInfo info) throws ExportException
helper
- the helper object.info
- all namespaces that this stylesheet may ever produce.
ExportException
- if construction fails.public static XsltExporterBase newFromConfig(ExportHelper helper, sk.uniba.euromath.config.bind.StylesheetType xslt, ExporterInfo info) throws IOException, ExportException
helper
- the exporter helper instance.xslt
- the XSLT definition.info
- the document class information.
IOException
- if I/O error occurs.
ExportException
- if stylesheet is unavailable or error occured
during initialization.public Map<String,Object> getProperties()
IExporter
getProperties
in interface IExporter
public void export(Source source, Result result, ExportContext context) throws ExportException
IExporter
Exports (transforms) the document from a single namespace and writes it to the result.
If the result is text or binary data and the result
is
instance of DOMResult
or SAXResult
then the
result must contain one text/cdata node with the result.
If needed then Coordinator may communicate with the Exporter directly via
the ObjectResult
class, however the plugin may throw an
exception when it does not support such return style. You can use this
result style to render images in the memory and give it to the renderer
(the Coordinator) directly, for example when rendering images to the
PDF-FOP result type.
If result does not specify the encoding then UTF-8 should be used as
default encoding. If the encoding is not supported by the result file
format then any valid encoding can be used. However, Coordinator is
strongly encouraged to provide the encoding whenever appropriate. If the
need of encoding can be avoided then use the appropriate means to avoid
it. For example if the result is DOM, SAX or if StreamResult
has non- null
writer.
If some required properties are missing or they have incorrect values
then UnsupportedOperation
exception should be thrown with
appropriate error message.
If object is offered as a source then the exporter must be able to free
any resources associated with the object (for example it must call
dispose()
on java.awt.Graphics
.
Both source
and result
must not be closed
after the export is done.
export
in interface IExporter
source
- the source of the transformation.
identifier
may be null
or it
may identify the datasource - previous exporter, source document etc.
SAXSource
:
reader
is never
null
,
input source
is almost always null
.
DOMSource
:
node
is never
null
. StreamSource
:
at least one of
StreamSource.getInputStream()
and
StreamSource.getReader()
is not
null
. If they are both non-null
you must
select one and use it exclusively - you cannot use read from both.
ObjectSource
: No assumptions can be made on the value of
object
- this protocol is user-specific.result
- the result of the transformation.
identifier
may be null
or you
may set it to identify this exporter.
SAXResult
:
content handler
is
never null
,
lexical handler
is not used and is null
.
node
is never
null
,
next sibling
is not used and is null
.
StreamResult
: at least one of
output stream
and writer
is
not null
. If they are both non-null
you
must select one and use it exclusively - you cannot write to both.
ObjectResult
: No assumptions can be made on the value of
object
- this protocol is user-specific.context
- the export context.
ExportException
- if something goes wrong in the process of
transformation - an unrecoverable error. All non-fatal errors and
warnings should be logged using the helper's log.public ExporterInfo getInfo()
IExporter
getInfo
in interface IExporter
public Object offerObject()
IExporter
When the exporter accepts the ObjectSource but wants to provide an object
as a result to the exporter E (for example it wants E to draw something
on a certain instance of Graphics), then return non-null
value. If this functionality is not needed then just return
null
- if E requires some object then it can create any
object as long as it is instance of class that this exporter expects.
The consumer (the one that receives the object, i.e. this) is responsible
for freeing the object if necessary (at the end of the export method),
even if this function returned null
.
If you want producer (the one that creates the object) to create custom
instances then provide a factory object. This trick is used with
http://www.uniba.sk/euromath/holder/java.awt.Graphics
holder - a factory is returned that is able to produce
java.awt.Graphics
instances.
offerObject
in interface IExporter
null
.protected static void fillParameters(Transformer transformer, ExportContext context)
transformer
- the transformer to feedcontext
- the values of parameters.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |