aboutsummaryrefslogtreecommitdiffstats
path: root/docparser.cpp
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2009-09-24 16:59:56 -0300
committerHugo Lima <hugo.lima@openbossa.org>2009-09-24 17:27:12 -0300
commit653dc64720ae78c633c2282519b9b21fb6491b3b (patch)
tree7177f362a83e3ca29d777cfb4a950bf800c63802 /docparser.cpp
parent9a34c9489429c17a36d248da91be10ca0f927d26 (diff)
Fix bug#38.
Diffstat (limited to 'docparser.cpp')
-rw-r--r--docparser.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/docparser.cpp b/docparser.cpp
index ddff5ffe..d6e8bf46 100644
--- a/docparser.cpp
+++ b/docparser.cpp
@@ -95,7 +95,19 @@ QString DocParser::applyDocModifications(const DocModificationList& mods, const
if (mods.isEmpty())
return xml;
- QString xsl = QLatin1String("<xsl:transform version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
+ bool hasXPathBasedModification = false;
+ foreach (DocModification mod, mods) {
+ if (mod.mode() == DocModification::XPathReplace) {
+ hasXPathBasedModification = true;
+ break;
+ }
+ }
+
+ if (!hasXPathBasedModification)
+ return xml;
+
+ QString xsl = QLatin1String("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<xsl:transform version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n"
"<xsl:template match=\"/\">\n"
" <xsl:apply-templates />\n"
"</xsl:template>\n"
@@ -140,7 +152,7 @@ QString DocParser::applyDocModifications(const DocModificationList& mods, const
int bufferSize;
QString result;
if (!xsltSaveResultToString(&buffer, &bufferSize, res.xslResult, res.xslt)) {
- result = QByteArray(reinterpret_cast<char*>(buffer), bufferSize);
+ result = QString::fromUtf8(reinterpret_cast<char*>(buffer), bufferSize);
std::free(buffer);
} else {
result = xml;