diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2009-09-24 16:59:56 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2009-09-24 17:27:12 -0300 |
commit | 653dc64720ae78c633c2282519b9b21fb6491b3b (patch) | |
tree | 7177f362a83e3ca29d777cfb4a950bf800c63802 /docparser.cpp | |
parent | 9a34c9489429c17a36d248da91be10ca0f927d26 (diff) |
Fix bug#38.
Diffstat (limited to 'docparser.cpp')
-rw-r--r-- | docparser.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/docparser.cpp b/docparser.cpp index ddff5ffe9..d6e8bf468 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; |