1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/xsltproc.cpp Wed Feb 15 12:54:55 2006 +0000
1.3 @@ -0,0 +1,91 @@
1.4 +#include "xsltproc.h"
1.5 +
1.6 +#include <iostream>
1.7 +#include <qmessagebox.h>
1.8 +
1.9 +#include "process.h"
1.10 +
1.11 +
1.12 +XSLTProc::XSLTProc ()
1.13 +{
1.14 + xsltprocessor="xsltproc";
1.15 + showOutput=false;
1.16 + dia=new ShowTextDialog;
1.17 +}
1.18 +
1.19 +XSLTProc::~XSLTProc ()
1.20 +{
1.21 + delete (dia);
1.22 +}
1.23 +
1.24 +void XSLTProc::addStringParam (const QString & k, const QString &v)
1.25 +{
1.26 + stringParamKey.append (k);
1.27 + stringParamVal.append (v);
1.28 +}
1.29 +
1.30 +void XSLTProc::setOutputFile (const QString &s)
1.31 +{
1.32 + outputFile=s;
1.33 +}
1.34 +
1.35 +void XSLTProc::setXSLFile(const QString &s)
1.36 +{
1.37 + xslFile=s;
1.38 +}
1.39 +
1.40 +void XSLTProc::setInputFile (const QString &s)
1.41 +{
1.42 + inputFile=s;
1.43 +}
1.44 +
1.45 +void XSLTProc::addOutput (const QString &s)
1.46 +{
1.47 + dia->append (s);
1.48 +}
1.49 +
1.50 +void XSLTProc::process()
1.51 +{
1.52 + ShowTextDialog dia;
1.53 + Process *xsltProc=new Process ();
1.54 + xsltProc->clearArguments();
1.55 + xsltProc->addArgument (xsltprocessor);
1.56 +
1.57 + QStringList::Iterator itk;
1.58 + QStringList::Iterator itv=stringParamVal.begin();
1.59 +
1.60 + for ( itk = stringParamKey.begin(); itk != stringParamKey.end(); ++itk )
1.61 + {
1.62 + xsltProc->addArgument ("--stringparam");
1.63 + xsltProc->addArgument (*itk);
1.64 + xsltProc->addArgument (*itv);
1.65 + ++itv;
1.66 + }
1.67 +
1.68 + xsltProc->addArgument ("--output");
1.69 + xsltProc->addArgument (outputFile);
1.70 + xsltProc->addArgument (xslFile);
1.71 + xsltProc->addArgument (inputFile);
1.72 + dia.append ("vym is executing: \n" + xsltProc->arguments().join(" ") );
1.73 + if (!xsltProc->start() )
1.74 + {
1.75 + QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
1.76 + QObject::tr("Could not start %1").arg(xsltprocessor) );
1.77 + } else
1.78 + {
1.79 + xsltProc->waitFinished();
1.80 + if (!xsltProc->normalExit() )
1.81 + QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
1.82 + QObject::tr("%1 didn't exit normally").arg(xsltprocessor) +
1.83 + xsltProc->getErrout() );
1.84 + else
1.85 + if (xsltProc->exitStatus()>0) showOutput=true;
1.86 +
1.87 + }
1.88 + dia.append ("\n");
1.89 + dia.append (xsltProc->getErrout());
1.90 + dia.append (xsltProc->getStdout());
1.91 +
1.92 + if (showOutput) dia.exec();
1.93 +}
1.94 +