aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docparser.cpp16
-rw-r--r--typesystem.cpp7
2 files changed, 18 insertions, 5 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;
diff --git a/typesystem.cpp b/typesystem.cpp
index ae5c3a1c..15166f35 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -777,9 +777,10 @@ bool Handler::startElement(const QString &, const QString &n,
const int validParent = StackElement::TypeEntryMask
| StackElement::ModifyFunction
| StackElement::ModifyField;
- if (current->parent && current->parent->type & validParent)
- m_docModifications << DocModification(attributes["xpath"], m_currentSignature);
- else {
+ if (current->parent && current->parent->type & validParent) {
+ QString signature = (current->type & StackElement::TypeEntryMask) ? QString() : m_currentSignature;
+ m_docModifications << DocModification(attributes["xpath"], signature);
+ } else {
m_error = "modify-documentation must be inside modify-function, "
"modify-field or other tags that creates a type";
return false;