xsltproc.cpp
branchrelease-1-12-maintained
changeset 63 e4d3a9313d04
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xsltproc.cpp	Mon Mar 30 07:50:51 2009 +0000
     1.3 @@ -0,0 +1,95 @@
     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 +extern bool debug;
    1.13 +
    1.14 +XSLTProc::XSLTProc ()
    1.15 +{
    1.16 +	xsltprocessor="xsltproc";
    1.17 +	showOutput=false;
    1.18 +	dia=new ShowTextDialog;
    1.19 +}
    1.20 +
    1.21 +XSLTProc::~XSLTProc ()
    1.22 +{
    1.23 +	delete (dia);
    1.24 +}
    1.25 +
    1.26 +void XSLTProc::addStringParam (const QString & k, const QString &v)
    1.27 +{
    1.28 +	stringParamKey.append (k);
    1.29 +	stringParamVal.append (v);
    1.30 +}
    1.31 +
    1.32 +void XSLTProc::setOutputFile    (const QString &s)
    1.33 +{
    1.34 +	outputFile=s;
    1.35 +}
    1.36 +
    1.37 +void XSLTProc::setXSLFile(const QString &s)
    1.38 +{
    1.39 +	xslFile=s;
    1.40 +}
    1.41 +
    1.42 +void XSLTProc::setInputFile     (const QString &s)
    1.43 +{
    1.44 +	inputFile=s;
    1.45 +}
    1.46 +
    1.47 +void XSLTProc::addOutput (const QString &s)
    1.48 +{
    1.49 +	dia->append (s);
    1.50 +}
    1.51 +
    1.52 +void XSLTProc::process()
    1.53 +{
    1.54 +	ShowTextDialog dia;
    1.55 +	QStringList args;
    1.56 +	Process *xsltProc=new Process ();
    1.57 +
    1.58 +	QStringList::Iterator itk;
    1.59 +	QStringList::Iterator itv=stringParamVal.begin();
    1.60 +
    1.61 +	for ( itk = stringParamKey.begin(); itk != stringParamKey.end(); ++itk ) 
    1.62 +	{
    1.63 +		args << "--stringparam";
    1.64 +		args << *itk;
    1.65 +		args << *itv;
    1.66 +		++itv;
    1.67 +    }
    1.68 +	
    1.69 +	args << "--output";
    1.70 +	args << outputFile;
    1.71 +	args << xslFile;
    1.72 +	args << inputFile;
    1.73 +	QString com=xsltprocessor+" "+args.join(" "); 
    1.74 +	if (debug) cout <<"xsltproc executing:\n"<<qPrintable(com)<<endl;
    1.75 +	dia.append ("vym is executing: \n" + com );	
    1.76 +	xsltProc->start(xsltprocessor,args);
    1.77 +	if (!xsltProc->waitForStarted() )
    1.78 +	{
    1.79 +		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
    1.80 +					   QObject::tr("Could not start %1").arg(xsltprocessor) );
    1.81 +	} else
    1.82 +	{
    1.83 +		if (!xsltProc->waitForFinished())
    1.84 +		{
    1.85 +			QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
    1.86 +			   QObject::tr("%1 didn't exit normally").arg(xsltprocessor) +
    1.87 +			   xsltProc->getErrout() );
    1.88 +			if (xsltProc->exitStatus()>0) showOutput=true;
    1.89 +		}	   
    1.90 +			
    1.91 +	}	
    1.92 +	dia.append ("\n");
    1.93 +	dia.append (xsltProc->getErrout());
    1.94 +	dia.append (xsltProc->getStdout());
    1.95 +	
    1.96 +	if (showOutput ||debug) dia.exec();
    1.97 +}
    1.98 +