Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
XSLTransform Class Reference

#include <elm/xom/XSLTransform.h>

+ Inheritance diagram for XSLTransform:

Public Member Functions

 XSLTransform (Document *stylesheet)
 
 XSLTransform (Document *stylesheet, NodeFactory *factory)
 
void setParameter (const string &name, const string &value)
 
void setParameter (const string &name, const string &ns, const string &value)
 
DocumenttoDocument (const Nodes &nodes)
 
String toString (void)
 
Nodes transform (Document *in)
 
Nodes transform (Nodes in)
 
DocumenttransformDocument (Document *in)
 
- Public Member Functions inherited from ErrorBase
 ErrorBase (ErrorHandler *error_handler=&ErrorHandler::DEFAULT)
 
void setErrorHandler (ErrorHandler *error_handler)
 
ErrorHandlergetErrorHandler (void) const
 

Additional Inherited Members

- Protected Member Functions inherited from ErrorBase
void onError (error_level_t level, const string &message)
 

Detailed Description

Serves as an interface to a XSLT processor. The following example shows how to apply an XSL Transformation to a XOM document and get the transformation result in the form of a XOM Nodes:

public static Nodes transform(Document in)
throws XSLException, ParsingException, IOException {
#include <elm/xom/Builder.h>
#include <elm/xom/XSLTransform.h>
Builder builder = new Builder();
Document *stylesheet = builder.build("mystylesheet.xsl");
XSLTransform transform(stylesheet);
Nodes nodes = transform.transform(doc);
Author
H. Cassé casse.nosp@m.@iri.nosp@m.t.fr

Constructor & Destructor Documentation

◆ XSLTransform() [1/2]

XSLTransform ( Document stylesheet)

Creates a new XSLTransform by reading the stylesheet from the supplied document.

Parameters
stylesheetdocument containing the stylesheet
Exceptions
XSLExceptionwhen the supplied document is not syntactically correct XSLT

◆ XSLTransform() [2/2]

XSLTransform ( Document stylesheet,
NodeFactory factory 
)

Creates a new XSLTransform by reading the stylesheet from the supplied document. The supplied factory will be used to create all nodes in the result tree, so that a transform can create instances of subclasses of the standard XOM classes. Because an XSL transformation generates a list of nodes rather than a document, the factory's startMakingDocument and finishMakingDocument methods are not called.

Parameters
stylesheetdocument containing the stylesheet
factorythe factory used to build nodes in the result tree
Exceptions
XSLExceptionwhen the supplied document is not syntactically correct XSLT

Member Function Documentation

◆ setParameter() [1/2]

void setParameter ( const string name,
const string ns,
const string value 
)

Supply a parameter to transformations performed by this object.

Parameters
namethe name of the parameter
namespacethe namespace URI of the parameter
valuethe value of the parameter

◆ setParameter() [2/2]

void setParameter ( const string name,
const string value 
)

Supply a parameter to transformations performed by this object.

Parameters
namethe name of the parameter
valuethe value of the parameter
Note
The parameter value must be a valid XPath expression, meaning that,
  • strings must be quoted with "'",
  • boolean value must converted to integer (zero for false, non-zero for true) or using functions true() or false().

References ListMap< K, T, C, E, A >::put().

◆ toDocument()

Document * toDocument ( const Nodes nodes)

Creates a new Nodes object from the input Nodes object by applying this object's stylesheet. The original Nodes object is not changed.

Parameters
indocument to transform
Returns
a Nodes containing the result of the transformation
Exceptions
XSLExceptionif the transformation fails, normally due to an XSLT error all nodes passed in in parameter are cleaned up

References ParentNode::appendChild(), Node::ELEMENT, NodeFactory::finishMakingDocument(), Nodes::get(), Node::kind(), Document::setRootElement(), Nodes::size(), and NodeFactory::startMakingDocument().

◆ toString()

String toString ( void  )

Returns a string form of this XSLTransform, suitable for debugging.

Returns
debugging string

References Document::toString().

◆ transform() [1/2]

Nodes transform ( Document in)

Creates a new Nodes from the input Document by applying this object's stylesheet. The original Document is not changed.

Parameters
indocument to transform
Returns
a Nodes containing the result of the transformation
Exceptions
XSLExceptionif the transformation fails, normally due to an XSLT error

◆ transform() [2/2]

Nodes transform ( Nodes  in)

Not currently supported.

◆ transformDocument()

Document * transformDocument ( Document in)

Transform a document and return it.

Parameters
indocument to transform.
Returns
transformed document.

References ListMap< K, T, C, E, A >::count(), Node::getNode(), NodeFactory::makeDocument(), and ListMap< K, T, C, E, A >::pairs().


The documentation for this class was generated from the following files:
elm::xom::XSLTransform::XSLTransform
XSLTransform(Document *stylesheet)
Definition: xom_XSLTransform.cpp:68
elm::t::in
typename type_info< T >::in_t in
Definition: type_info.h:283
elm::xom::XSLTransform::transform
Nodes transform(Document *in)
Definition: xom_XSLTransform.cpp:179