1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include "xsltproc.h"
#include <iostream>
#include <qmessagebox.h>
#include "process.h"
XSLTProc::XSLTProc ()
{
xsltprocessor="xsltproc";
showOutput=false;
dia=new ShowTextDialog;
}
XSLTProc::~XSLTProc ()
{
delete (dia);
}
void XSLTProc::addStringParam (const QString & k, const QString &v)
{
stringParamKey.append (k);
stringParamVal.append (v);
}
void XSLTProc::setOutputFile (const QString &s)
{
outputFile=s;
}
void XSLTProc::setXSLFile(const QString &s)
{
xslFile=s;
}
void XSLTProc::setInputFile (const QString &s)
{
inputFile=s;
}
void XSLTProc::addOutput (const QString &s)
{
dia->append (s);
}
void XSLTProc::process()
{
ShowTextDialog dia;
Process *xsltProc=new Process ();
xsltProc->clearArguments();
xsltProc->addArgument (xsltprocessor);
QStringList::Iterator itk;
QStringList::Iterator itv=stringParamVal.begin();
for ( itk = stringParamKey.begin(); itk != stringParamKey.end(); ++itk )
{
xsltProc->addArgument ("--stringparam");
xsltProc->addArgument (*itk);
xsltProc->addArgument (*itv);
++itv;
}
xsltProc->addArgument ("--output");
xsltProc->addArgument (outputFile);
xsltProc->addArgument (xslFile);
xsltProc->addArgument (inputFile);
dia.append ("vym is executing: \n" + xsltProc->arguments().join(" ") );
if (!xsltProc->start() )
{
QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
QObject::tr("Could not start %1").arg(xsltprocessor) );
} else
{
xsltProc->waitFinished();
if (!xsltProc->normalExit() )
QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
QObject::tr("%1 didn't exit normally").arg(xsltprocessor) +
xsltProc->getErrout() );
else
if (xsltProc->exitStatus()>0) showOutput=true;
}
dia.append ("\n");
dia.append (xsltProc->getErrout());
dia.append (xsltProc->getStdout());
if (showOutput) dia.exec();
}
|