The xslt::stylesheet class is used to hold information about an XSLT stylesheet. More...
#include <stylesheet.h>
Public Types | |
typedef std::map< std::string, std::string > | param_type |
Type for passing parameters to the stylesheet. | |
Public Member Functions | |
stylesheet (const char *filename) | |
Create a new xslt::stylesheet object and load and parse the stylesheet in the given filename. | |
stylesheet (xml::document doc) | |
Create a new xslt::stylesheet object from an xml::document object that contains the parsed stylesheet. | |
~stylesheet () | |
Clean up after an xslt::stylesheet. | |
bool | apply (const xml::document &doc, xml::document &result) |
Apply this stylesheet to the given XML document. | |
bool | apply (const xml::document &doc, xml::document &result, const param_type &with_params) |
Apply this stylesheet to the given XML document. | |
xml::document & | apply (const xml::document &doc) |
Apply this stylesheet to the given XML document. | |
xml::document & | apply (const xml::document &doc, const param_type &with_params) |
Apply this stylesheet to the given XML document. | |
const std::string & | get_error_message () const |
If you used one of the xslt::stylesheet::apply member functions that return a bool, you can use this function to get the text message for the transformation error. |
The xslt::stylesheet class is used to hold information about an XSLT stylesheet.
You can use it to load in a stylesheet and then use that stylesheet to transform an XML document to something else.
typedef std::map<std::string, std::string> xslt::stylesheet::param_type |
Type for passing parameters to the stylesheet.
xslt::stylesheet::stylesheet | ( | const char * | filename | ) | [explicit] |
Create a new xslt::stylesheet object and load and parse the stylesheet in the given filename.
filename | The name of the file that contains the stylesheet. |
xslt::stylesheet::stylesheet | ( | xml::document | doc | ) | [explicit] |
Create a new xslt::stylesheet object from an xml::document object that contains the parsed stylesheet.
The given xml::document is passed by value. This is needed because the stylesheet will own the document and free it.
doc | The parsed stylesheet. |
xslt::stylesheet::~stylesheet | ( | ) |
Clean up after an xslt::stylesheet.
xml::document& xslt::stylesheet::apply | ( | const xml::document & | doc, | |
const param_type & | with_params | |||
) |
Apply this stylesheet to the given XML document.
The results document is returned. If there is an error during transformation, this function will throw a std::runtime_error exception.
Each time you call this member function, the xml::document object that was returned from the last call becomes invalid. That is, of course, unless you copied it first.
doc | The XML document to transform. | |
with_params | Override xsl:param elements using the given key/value map |
xml::document& xslt::stylesheet::apply | ( | const xml::document & | doc | ) |
Apply this stylesheet to the given XML document.
The results document is returned. If there is an error during transformation, this function will throw a std::runtime_error exception.
Each time you call this member function, the xml::document object that was returned from the last call becomes invalid. That is, of course, unless you copied it first.
doc | The XML document to transform. |
bool xslt::stylesheet::apply | ( | const xml::document & | doc, | |
xml::document & | result, | |||
const param_type & | with_params | |||
) |
Apply this stylesheet to the given XML document.
The result document is placed in the second document parameter.
doc | The XML document to transform. | |
result | The result tree after applying this stylesheet. | |
with_params | Override xsl:param elements using the given key/value map |
bool xslt::stylesheet::apply | ( | const xml::document & | doc, | |
xml::document & | result | |||
) |
Apply this stylesheet to the given XML document.
The result document is placed in the second document parameter.
doc | The XML document to transform. | |
result | The result tree after applying this stylesheet. |
const std::string& xslt::stylesheet::get_error_message | ( | ) | const |
If you used one of the xslt::stylesheet::apply member functions that return a bool, you can use this function to get the text message for the transformation error.
If you are using one of the apply member functions that throws exceptions, this function should not be used. The text message for the transformation error will be given to the std::runtime_error constructor.