15 #include <q3dragobject.h> 19 #include <libxml/xmlmemory.h> 20 #include <libxml/debugXML.h> 21 #include <libxml/HTMLtree.h> 22 #include <libxml/xmlIO.h> 23 #include <libxml/xinclude.h> 24 #include <libxml/catalog.h> 25 #include <libxslt/xslt.h> 26 #include <libxslt/xsltInternals.h> 27 #include <libxslt/transform.h> 28 #include <libxslt/xsltutils.h> 33 #include "../../config.h" 40 text.replace(
"&",
"&");
41 text.replace(
"\"",
""");
42 text.replace(
"'",
"'");
43 text.replace(
"<",
"<");
44 text.replace(
">",
">");
45 text.replace(
"\n",
" ");
46 text.replace(
"\r",
" ");
52 xmlSubstituteEntitiesDefault(1);
53 xmlLoadExtDtdDefaultValue = 1;
54 xsltStylesheetPtr cur = xsltParseStylesheetFile( (
const xmlChar *) QString(
THEMES_PATH + theme +
"/theme.xsl").ascii() );
56 QString xmlFile = QString(outputPath +
"/Album.xml");
57 xmlDocPtr doc = xmlParseFile( QFile::encodeName(xmlFile) );
59 const char* params[5];
61 params[0] =
"outputPath";
62 QString quotedPath = outputPath;
70 quotedPath = Q3UriDrag::localFileToUri( quotedPath );
73 params[1] = quotedPath.prepend(
'\"').append(
'\"').ascii();
75 params[2] =
"smallWebExport";
82 xmlDocPtr res = xsltApplyStylesheet( cur, doc, params);
83 xsltFreeStylesheet( cur );
96 std::cout <<
"Can't find update.xsl! Skipping auto-update!\n";
100 xmlSubstituteEntitiesDefault(1);
101 xmlLoadExtDtdDefaultValue = 1;
103 xsltStylesheetPtr stylesheet;
104 xmlDocPtr inputDoc, outputDoc;
106 stylesheet = xsltParseStylesheetFile( (
const xmlChar *) QString(
XMLCONVERSION_PATH +
"update.xsl").ascii() );
108 QString xmlFile = QString( inputPath +
"/Album.xml" );
109 xmlFile = QDir::convertSeparators( xmlFile );
110 inputDoc = xmlParseFile( QFile::encodeName(xmlFile) );
112 const char* params[3];
113 params[0] =
"outputPath";
115 QString quotedPath = inputPath;
123 quotedPath = Q3UriDrag::localFileToUri( quotedPath );
127 params[1] = quotedPath.prepend(
'\"').append(
'\"').ascii();
134 QDir workingDir( inputPath );
142 outputDoc = xsltApplyStylesheet( stylesheet, inputDoc, params );
146 if(workingDir.exists(
"Album.updated" ))
150 xmlFreeDoc( inputDoc );
153 inputDoc = outputDoc;
157 workingDir.remove( inputPath +
"/Album.updated" );
163 FILE* outfile = fopen( QFile::encodeName(xmlFile),
"w" );
164 xsltSaveResultToFile( outfile, inputDoc, stylesheet);
169 xsltFreeStylesheet( stylesheet );
170 xmlFreeDoc( inputDoc );
171 xmlFreeDoc( outputDoc );
172 xsltCleanupGlobals();
QString XMLCONVERSION_PATH