[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kdoctools
From: Frerich Raabe <raabe () kde ! org>
Date: 2005-02-14 11:11:40
Message-ID: 20050214111140.0C72C1D1A9 () office ! kde ! org
[Download RAW message or body]
CVS commit by raabe:
- Make it possible to pass parameters to stylesheets. New feature, but
coolo didn't complained, and this is necessary for a nice KDE_MANS fix.
M +29 -6 meinproc.cpp 1.40
M +6 -5 xslt.cpp 1.70
M +3 -1 xslt.h 1.15
--- kdelibs/kdoctools/meinproc.cpp #1.39:1.40
@@ -27,4 +27,5 @@
#include <qfileinfo.h>
#include <kprocess.h>
+#include <qvaluevector.h>
extern int xmlLoadExtDtdDefaultValue;
@@ -79,4 +80,7 @@ static KCmdLineOptions options[] =
{ "cache <file>", I18N_NOOP( "Create a cache file for the document" ), 0},
{ "srcdir <dir>", I18N_NOOP( "Set the srcdir, for kdelibs" ), 0},
+
+ // XXX Un-comment after KDE 3.4
+ { "param <key>=<value>", /*I18N_NOOP( "Parameters to pass to the stylesheet" )*/ 0, 0},
{ "+xml", I18N_NOOP("The file to transform"), 0},
KCmdLineLastOption // End of options.
@@ -181,4 +185,26 @@ int main(int argc, char **argv) {
xmlLoadExtDtdDefaultValue = 1;
+ QValueVector<const char *> params;
+ if (args->isSet( "output" ) ) {
+ params.append( qstrdup( "outputFile" ) );
+ params.append( qstrdup( QFile::decodeName( args->getOption( "output" ) ).latin1() ) );
+ }
+ {
+ const QCStringList paramList = args->getOptionList( "param" );
+ QCStringList::ConstIterator it = paramList.begin();
+ QCStringList::ConstIterator end = paramList.end();
+ for ( ; it != end; ++it ) {
+ const QCString tuple = *it;
+ const int ch = tuple.find( '=' );
+ if ( ch == -1 ) {
+ kdError() << "Key-Value tuple '" << tuple << "' lacks a '='!" << endl;
+ return( 2 );
+ }
+ params.append( qstrdup( tuple.left( ch ) ) );
+ params.append( qstrdup( tuple.mid( ch + 1 ) ) );
+ }
+ }
+ params.append( NULL );
+
bool index = args->isSet( "htdig" );
QString tss = args->getOption( "stylesheet" );
@@ -198,8 +224,5 @@ int main(int argc, char **argv) {
xmlDocPtr doc = xmlParseFile( QFile::encodeName( args->arg( 0 ) ) );
- // the params can be used to customize it more flexible
- const char *params[16 + 1];
- params[0] = NULL;
- xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, params);
+ xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, ¶ms[0]);
xmlFreeDoc(doc);
@@ -229,5 +252,5 @@ int main(int argc, char **argv) {
} else {
- QString output = transform(args->arg( 0 ) , tss);
+ QString output = transform(args->arg( 0 ) , tss, params);
if (output.isEmpty()) {
fprintf(stderr, "unable to parse %s\n", args->arg( 0 ));
--- kdelibs/kdoctools/xslt.cpp #1.69:1.70
@@ -26,4 +26,5 @@
#include <bzip2/kbzip2filter.h>
#include <klibloader.h>
+#include <qvaluevector.h>
#if !defined( SIMPLE_XSLT )
@@ -47,5 +48,6 @@ int closeQString(void * context) {
}
-QString transform( const QString &pat, const QString& tss)
+QString transform( const QString &pat, const QString& tss,
+ const QValueVector<const char *> ¶ms )
{
QString parsed;
@@ -74,9 +76,8 @@ QString transform( const QString &pat, c
return parsed;
- // the params can be used to customize it more flexible
- const char *params[16 + 1];
- params[0] = NULL;
INFO(i18n("Applying stylesheet"));
- xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, params);
+ QValueVector<const char *> p = params;
+ p.append( NULL );
+ xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, const_cast<const char **>(&p[0]));
xmlFreeDoc(doc);
if (res != NULL) {
--- kdelibs/kdoctools/xslt.h #1.14:1.15
@@ -3,6 +3,8 @@
#include <libxml/parser.h>
+#include <qvaluevector.h>
-QString transform(const QString &file, const QString& stylesheet);
+QString transform(const QString &file, const QString& stylesheet,
+ const QValueVector<const char *> ¶ms = QValueVector<const char *>());
QString splitOut(const QString &parsed, int index);
void fillInstance(KInstance &ins, const QString &srcdir = QString::null );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic