File: xsltproc.cpp

package info (click to toggle)
vym 1.10.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,376 kB
  • ctags: 1,926
  • sloc: cpp: 18,468; xml: 277; sh: 211; perl: 89; makefile: 26
file content (94 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
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
92
93
94
#include "xsltproc.h"

#include <iostream>
#include <qmessagebox.h>

#include "process.h"


extern bool debug;

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;
	QStringList args;
	Process *xsltProc=new Process ();

	QStringList::Iterator itk;
	QStringList::Iterator itv=stringParamVal.begin();

	for ( itk = stringParamKey.begin(); itk != stringParamKey.end(); ++itk ) 
	{
		args << "--stringparam";
		args << *itk;
		args << *itv;
		++itv;
    }
	
	args << "--output";
	args << outputFile;
	args << xslFile;
	args << inputFile;
	QString com=xsltprocessor+" "+args.join(" "); 
	if (debug) cout <<"xsltproc executing:\n"<<com.ascii()<<endl;
	dia.append ("vym is executing: \n" + com );	
	xsltProc->start(xsltprocessor,args);
	if (!xsltProc->waitForStarted() )
	{
		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
					   QObject::tr("Could not start %1").arg(xsltprocessor) );
	} else
	{
		if (!xsltProc->waitForFinished())
			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();
}