xmlwrapp
Lightweight C++ XML parsing library
|
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. More... | |
Public Member Functions | |
stylesheet (const char *filename, xml::error_handler &on_error=xml::throw_on_error) | |
Create a new xslt::stylesheet object and load and parse the stylesheet in the given filename. More... | |
stylesheet (xml::document doc, xml::error_handler &on_error=xml::throw_on_error) | |
Create a new xslt::stylesheet object from an xml::document object that contains the parsed stylesheet. More... | |
~stylesheet () | |
Clean up after an xslt::stylesheet. More... | |
bool | apply (const xml::document &doc, xml::document &result) |
Apply this stylesheet to the given XML document. More... | |
bool | apply (const xml::document &doc, xml::document &result, const param_type &with_params) |
Apply this stylesheet to the given XML document. More... | |
bool | apply (const xml::document &doc, xml::document &result, xml::error_handler &on_error) |
Apply this stylesheet to the given XML document. More... | |
bool | apply (const xml::document &doc, xml::document &result, const param_type &with_params, xml::error_handler &on_error) |
Apply this stylesheet to the given XML document. More... | |
xml::document & | apply (const xml::document &doc, xml::error_handler &on_error=xml::throw_on_error) |
Apply this stylesheet to the given XML document. More... | |
xml::document & | apply (const xml::document &doc, const param_type &with_params, xml::error_handler &on_error=xml::throw_on_error) |
Apply this stylesheet to the given XML document. More... | |
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. More... | |
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.
|
explicit |
Create a new xslt::stylesheet object and load and parse the stylesheet in the given filename.
Errors are handled by on_error handler; by default, xml::exception is thrown on errors. If there's a fatal error that prevents the stylesheet from being loaded and the error handler doesn't throw an exception, the constructor will throw xml::exception anyway.
filename | The name of the file that contains the stylesheet. |
on_error | Handler called to process errors and warnings (since 0.7.0). |
|
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.
Errors are handled by on_error handler; by default, xml::exception is thrown on errors. If there's a fatal error that prevents the stylesheet from being loaded and the error handler doesn't throw an exception, the constructor will throw xml::exception anyway.
doc | The parsed stylesheet. |
on_error | Handler called to process errors and warnings (since 0.7.0). |
xslt::stylesheet::~stylesheet | ( | ) |
Clean up after an xslt::stylesheet.
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. |
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, | ||
xml::error_handler & | on_error | ||
) |
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. |
on_error | Handler called to process errors and warnings (since 0.7.0). |
bool xslt::stylesheet::apply | ( | const xml::document & | doc, |
xml::document & | result, | ||
const param_type & | with_params, | ||
xml::error_handler & | on_error | ||
) |
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 |
on_error | Handler called to process errors and warnings (since 0.7.0). |
xml::document& xslt::stylesheet::apply | ( | const xml::document & | doc, |
xml::error_handler & | on_error = xml::throw_on_error |
||
) |
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 xml::exception 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. |
on_error | Handler called to process errors and warnings (since 0.7.0). |
xml::document& xslt::stylesheet::apply | ( | const xml::document & | doc, |
const param_type & | with_params, | ||
xml::error_handler & | on_error = xml::throw_on_error |
||
) |
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 xml::exception 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 |
on_error | Handler called to process errors and warnings (since 0.7.0). |
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 xml::exception constructor.