예제 #1
0
void XmlDocumentUnitTests::testXslTransform()
{
    // check test xml file
	std::wstring xmlfile = GetLocalFileLocation(L"simple.xml");
	std::wcout << std::endl << L"Xml: " << xmlfile;
    CPPUNIT_ASSERT(File::FileExists(xmlfile));
    // check test xsl file
	std::wstring xslfile = GetLocalFileLocation(L"simple.xsl");
	std::wcout << std::endl << L"Xsl: " << xslfile;
    CPPUNIT_ASSERT(File::FileExists(xslfile));
    // transform
	AppSecInc::Xml::XmlDocument xml;
	xml.Load(xmlfile);
	AppSecInc::Xml::XmlDocument transformedXml;
	std::wstring transformResult = xml.XslTransform(xslfile);
	transformedXml.LoadXml(transformResult);
    // load the result
	CPPUNIT_ASSERT(transformResult.length() > 0);
}
예제 #2
0
CA_API UINT __stdcall Xml_XslTransform(MSIHANDLE hInstall)
{
    MSI_EXCEPTION_HANDLER_PROLOG;
    MsiInstall msiInstall(hInstall);

    std::wstring filename = msiInstall.GetProperty(L"XML_FILENAME");
    AppSecInc::Xml::XmlDocument doc;
    doc.Load(filename);

    std::wstring xslt_filename = msiInstall.GetProperty(L"XSLT_FILENAME");
    std::wstring xslt_result_filename = msiInstall.GetProperty(L"XSLT_RESULT_FILENAME");

    std::wstring transformedData = doc.XslTransform(xslt_filename);

    std::string char_data = AppSecInc::StringUtils::wc2mb(transformedData);
    std::vector<char> binary_data;
    binary_data.assign(char_data.begin(), char_data.end());
    AppSecInc::File::FileWrite(xslt_result_filename, binary_data);

    MSI_EXCEPTION_HANDLER_EPILOG;
    return ERROR_SUCCESS;
}