CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | List of all members
ctkCmdLineModuleXslTransform Class Reference

Transforms a given XML input using an XML stylesheet. More...

#include <Libs/CommandLineModules/Core/ctkCmdLineModuleXslTransform.h>

Inheritance diagram for ctkCmdLineModuleXslTransform:
Inheritance graph
[legend]
Collaboration diagram for ctkCmdLineModuleXslTransform:
Collaboration graph
[legend]

Public Member Functions

void bindVariable (const QString &name, const QVariant &value)
 Binds the variable name to the value so that $name can be used from within the query to refer to the value. In the default XslTransformation, the widget classes are variable and can be replaced with a new binding. More...
 
 ctkCmdLineModuleXslTransform (QIODevice *input=0, QIODevice *output=0)
 
virtual bool error () const
 Returns true if an error occured. More...
 
virtual QString errorString () const
 Returns the error message if any. More...
 
bool formatXmlOutput () const
 Returns true if the XSL output will be formatted. More...
 
QIODevice * output () const
 Get the output device to which the transformation will be written. More...
 
void setFormatXmlOutput (bool format)
 Formats the XSL output to be human-readable. More...
 
void setOutput (QIODevice *output)
 Set the output device to which the transformation will be written. More...
 
void setOutputSchema (QIODevice *output)
 Set an XML schema for output validation. More...
 
void setValidateOutput (bool validate)
 Sets the output validation mode. More...
 
void setXslExtraTransformation (QIODevice *transformation)
 XSL to be injected in the main XSL. More...
 
void setXslExtraTransformations (const QList< QIODevice * > &transformations)
 
void setXslTransformation (QIODevice *transformation)
 Sets the XSL transformation. More...
 
bool transform ()
 Transforms an XML input via a XSL transformation. More...
 
bool validateOutput () const
 Get the output validation mode. More...
 
virtual ~ctkCmdLineModuleXslTransform ()
 
- Public Member Functions inherited from ctkCmdLineModuleXmlValidator
 ctkCmdLineModuleXmlValidator (QIODevice *input=0)
 
QIODevice * input () const
 Get the XML input device. More...
 
void setInput (QIODevice *input)
 Set the XML input. More...
 
void setInputSchema (QIODevice *input)
 Set the XML schema to be used during validation. More...
 
virtual bool validateInput ()
 Validate the XML input against the XML schema set via setInputSchema(). More...
 
 ~ctkCmdLineModuleXmlValidator ()
 

Detailed Description

Transforms a given XML input using an XML stylesheet.

You must call setInput(), setOutput() and setXslTransformation() before calling transform().

See also
ctkCmdLineModuleXmlValidator

Definition at line 43 of file ctkCmdLineModuleXslTransform.h.

Constructor & Destructor Documentation

◆ ctkCmdLineModuleXslTransform()

ctkCmdLineModuleXslTransform::ctkCmdLineModuleXslTransform ( QIODevice *  input = 0,
QIODevice *  output = 0 
)

◆ ~ctkCmdLineModuleXslTransform()

virtual ctkCmdLineModuleXslTransform::~ctkCmdLineModuleXslTransform ( )
virtual

Member Function Documentation

◆ bindVariable()

void ctkCmdLineModuleXslTransform::bindVariable ( const QString &  name,
const QVariant &  value 
)

Binds the variable name to the value so that $name can be used from within the query to refer to the value. In the default XslTransformation, the widget classes are variable and can be replaced with a new binding.

See also
QXmlQuery::bindVariable()

◆ error()

virtual bool ctkCmdLineModuleXslTransform::error ( ) const
virtual

Returns true if an error occured.

transform() sets the error flag if an error occured when transforming the XML file into XSL or validating the transformation.

See also
errorString

Reimplemented from ctkCmdLineModuleXmlValidator.

◆ errorString()

virtual QString ctkCmdLineModuleXslTransform::errorString ( ) const
virtual

Returns the error message if any.

transform() sets the error message if an error occured when transforming the XML file into XSL.

See also
error

Reimplemented from ctkCmdLineModuleXmlValidator.

◆ formatXmlOutput()

bool ctkCmdLineModuleXslTransform::formatXmlOutput ( ) const

Returns true if the XSL output will be formatted.

Returns
true if the ouptut will be formatted, false otherwise.

◆ output()

QIODevice* ctkCmdLineModuleXslTransform::output ( ) const

Get the output device to which the transformation will be written.

Returns
The output device.

◆ setFormatXmlOutput()

void ctkCmdLineModuleXslTransform::setFormatXmlOutput ( bool  format)

Formats the XSL output to be human-readable.

It is assumed that the XSL output is valid XML. The output will be formatted with an indentation depth of four spaces. Note that setting format to true increases compuational overhead and memory requirements and is usually only done for testing or debugging purposes.

◆ setOutput()

void ctkCmdLineModuleXslTransform::setOutput ( QIODevice *  output)

Set the output device to which the transformation will be written.

Parameters
outputThe output device.

If no output device is set, a default device will be used.

◆ setOutputSchema()

void ctkCmdLineModuleXslTransform::setOutputSchema ( QIODevice *  output)

Set an XML schema for output validation.

Parameters
outputThe XML schema against which the transformation will be validated.

Output validation will only be done if validateOutput() returns true.

◆ setValidateOutput()

void ctkCmdLineModuleXslTransform::setValidateOutput ( bool  validate)

Sets the output validation mode.

Parameters
validateIf true, the output will be validated against the XML schema provided via setOutputSchema(). If validate is false, no output validation takes place.

◆ setXslExtraTransformation()

void ctkCmdLineModuleXslTransform::setXslExtraTransformation ( QIODevice *  transformation)

XSL to be injected in the main XSL.

This can be used to potentially overwrite templates. To avoid ambiguity, specify a priority > 1 in your overwriting templates

Parameters
transformationExtra XSL transformation fragment.

◆ setXslExtraTransformations()

void ctkCmdLineModuleXslTransform::setXslExtraTransformations ( const QList< QIODevice * > &  transformations)

◆ setXslTransformation()

void ctkCmdLineModuleXslTransform::setXslTransformation ( QIODevice *  transformation)

Sets the XSL transformation.

Use this method to set the XSL transformation for this instance. Trying to transform the input without setting a transformation will result in runtime errors.

Parameters
transformationThe XSL transformation.

◆ transform()

bool ctkCmdLineModuleXslTransform::transform ( )

Transforms an XML input via a XSL transformation.

This method assumes that the input set via setInput() or supplied in the constructor is a valid, non empty XML fragment and that setOutput() and setXslTransformation() was called with non-null arguments.

Returns

◆ validateOutput()

bool ctkCmdLineModuleXslTransform::validateOutput ( ) const

Get the output validation mode.

Returns
true if the output will be validated, false otherwise.

The documentation for this class was generated from the following file: