ui-gxmlcpp 1.4.6
XSLTProc.cpp

XSLTProc program; a simple clone of libxslt's xsltproc. Binary should be installed as ui-gxmlcpp-xsltproc.

// Local configuration
#include "config.h"
// STDC++
#include <iostream>
#include <cassert>
// C++ libraries
int main(int argc, char** argv)
{
try
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0] << " XSL-FILE XML-FILE" << std::endl;
exit(1);
}
// libxml2/xslt global configuration
conf.setEXSLT();
// Parse xsl and xml trees
UI::GXML::XSLTree xslTree(UI::GXML::Tree::File_, argv[1]);
UI::GXML::Tree xmlTree(UI::GXML::Tree::File_, argv[2]);
// Get xsl translation result (with parameter example; this program should be updated to accept params via arguments)
UI::GXML::XSLTransTree xslTransTree(xslTree, xmlTree, UI::GXML::XSLTransTree::Params().add("example_only_param1", "value1").add("example_only_param2", "value2"));
// Get xsl translation result dump
// Note: For simplicity (i.e., if you don't need to hold/cache/work
// with the result) you could also simply use Tree::dump())
UI::GXML::XSLTransTree::Dump dump(xslTransTree);
// Output xsl translation dump
std::cerr << "Encoding is: " << dump.getEncoding() << std::endl;
std::cout << dump.get();
}
catch (std::exception const & e)
{
std::cerr << "Error: " << e.what() << std::endl;
}
}
libxml2/libxslt configuration helper.
Definition Conf.hpp:26
Conf & setEXSLT()
Register exslt functions for use with xsl transformations.
Definition Conf.cpp:71
XML tree.
Definition Tree.hpp:31
XSLTransTree serializer.
Definition XSLTransTree.hpp:67
std::string getEncoding() const
See XSLTree::getOutputEncoding().
Definition XSLTransTree.cpp:103
Parameter abstraction for xsl translations.
Definition XSLTransTree.hpp:49
XSL translation result tree.
Definition XSLTransTree.hpp:36
XSL (stylesheet) Tree.
Definition XSLTree.hpp:28