ui-gxmlcpp  1.4.4
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;
}
}
UI::GXML::XSLTransTree::Dump::getEncoding
std::string getEncoding() const
See XSLTree::getOutputEncoding().
Definition: XSLTransTree.cpp:103
UI::GXML::XSLTree
XSL (stylesheet) Tree.
Definition: XSLTree.hpp:27
Tree.hpp
UI::GXML::Conf
libxml2/libxslt configuration helper.
Definition: Conf.hpp:25
UI::GXML::Conf::setEXSLT
Conf & setEXSLT()
Register exslt functions for use with xsl transformations.
Definition: Conf.cpp:71
XSLTree.hpp
UI::GXML::XSLTransTree::Dump
XSLTransTree serializer.
Definition: XSLTransTree.hpp:66
UI::GXML::XSLTransTree
XSL translation result tree.
Definition: XSLTransTree.hpp:35
UI::GXML::Tree
XML tree.
Definition: Tree.hpp:30
Conf.hpp
UI::GXML::XSLTransTree::Params
Parameter abstraction for xsl translations.
Definition: XSLTransTree.hpp:48
XSLTransTree.hpp