#include <qstring.h>
#include <qdir.h>
#include <qfile.h>
#include <q3dragobject.h>
#include <iostream>
#include <string>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlIO.h>
#include <libxml/xinclude.h>
#include <libxml/catalog.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include <stdio.h>
#include "xmlTools.h"
#include "../../config.h"
Go to the source code of this file.
§ fixXMLString()
QString fixXMLString |
( |
QString |
text | ) |
|
Fix strings before exporting to XML such that & becomes &, etc...
Definition at line 36 of file xmlTools.cpp.
Referenced by Subalbum::exportToXML(), Photo::exportToXML(), and Album::exportToXML().
40 text.replace(
"&",
"&");
41 text.replace(
"\"",
""");
42 text.replace(
"'",
"'");
43 text.replace(
"<",
"<");
44 text.replace(
">",
">");
45 text.replace(
"\n",
" ");
46 text.replace(
"\r",
" ");
§ transformXMLtoHTML()
void transformXMLtoHTML |
( |
QString |
outputPath, |
|
|
QString |
theme, |
|
|
bool |
smallWebExport |
|
) |
| |
Definition at line 50 of file xmlTools.cpp.
References THEMES_PATH.
Referenced by Album::exportCompressedWebAlbum(), and Album::exportToDisk().
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 );
§ updateXML()
void updateXML |
( |
QString |
inputPath | ) |
|
Definition at line 90 of file xmlTools.cpp.
References XMLCONVERSION_PATH.
Referenced by Album::importFromDisk().
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