Merge pathToAbsoluteSchemaString and pathToSchemaString

These functions did almost the same thing, the only difference was that
the former inserted module prefixes everyhwere and the other didn't.
The new function takes an argument specifying whether to insert prefixes
everyhwere.

pathToSchemaString also checks whether a path is absolute or relative
and prepends a slash. This means, that it's no longer possible to
convert and absolute path to a string with no leading slash. The
StaticSchema class had to be changed accordingly, because it stored
absolute paths in strings without a leading slash (because it was
designed before absolute paths existed).

The fact that this was split into two functions helped find an error in
a later patch.

Change-Id: I6112cb5982919b51b61152f355771a52dd467c6e
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index 3a486a5..bdb3447 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -158,58 +158,42 @@
     return boost::apply_visitor(nodeToSchemaStringVisitor(), node.m_suffix);
 }
 
-std::string pathToDataString(const dataPath_& path)
+std::string pathToDataString(const dataPath_& path, Prefixes prefixes)
 {
     std::string res;
     if (path.m_scope == Scope::Absolute) {
         res = "/";
     }
-    for (const auto it : path.m_nodes)
+
+    for (const auto it : path.m_nodes) {
         if (it.m_prefix)
             res = joinPaths(res, it.m_prefix.value().m_name + ":" + boost::apply_visitor(nodeToDataStringVisitor(), it.m_suffix));
         else
-            res = joinPaths(res, boost::apply_visitor(nodeToDataStringVisitor(), it.m_suffix));
+            res = joinPaths(res, (prefixes == Prefixes::Always ? path.m_nodes.at(0).m_prefix.value().m_name + ":" : "") + boost::apply_visitor(nodeToDataStringVisitor(), it.m_suffix));
+    }
 
     return res;
 }
 
-std::string pathToAbsoluteSchemaString(const dataPath_& path)
-{
-    return pathToAbsoluteSchemaString(dataPathToSchemaPath(path));
-}
-
-std::string pathToAbsoluteSchemaString(const schemaPath_& path)
+std::string pathToSchemaString(const schemaPath_& path, Prefixes prefixes)
 {
     std::string res;
-    if (path.m_nodes.empty()) {
-        return "";
+    if (path.m_scope == Scope::Absolute) {
+        res = "/";
     }
 
-    auto topLevelModule = path.m_nodes.at(0).m_prefix.value();
     for (const auto it : path.m_nodes) {
         if (it.m_prefix)
             res = joinPaths(res, it.m_prefix.value().m_name + ":" + boost::apply_visitor(nodeToSchemaStringVisitor(), it.m_suffix));
         else
-            res = joinPaths(res, topLevelModule.m_name + ":" + boost::apply_visitor(nodeToSchemaStringVisitor(), it.m_suffix));
+            res = joinPaths(res, (prefixes == Prefixes::Always ? path.m_nodes.at(0).m_prefix.value().m_name + ":" : "") + boost::apply_visitor(nodeToSchemaStringVisitor(), it.m_suffix));
     }
     return res;
 }
 
-std::string pathToSchemaString(const schemaPath_& path)
+std::string pathToSchemaString(const dataPath_& path, Prefixes prefixes)
 {
-    std::string res;
-    for (const auto it : path.m_nodes) {
-        if (it.m_prefix)
-            res = joinPaths(res, it.m_prefix.value().m_name + ":" + boost::apply_visitor(nodeToSchemaStringVisitor(), it.m_suffix));
-        else
-            res = joinPaths(res, boost::apply_visitor(nodeToSchemaStringVisitor(), it.m_suffix));
-    }
-    return res;
-}
-
-std::string pathToSchemaString(const dataPath_& path)
-{
-    return pathToSchemaString(dataPathToSchemaPath(path));
+    return pathToSchemaString(dataPathToSchemaPath(path), prefixes);
 }
 
 struct dataSuffixToSchemaSuffix : boost::static_visitor<decltype(schemaNode_::m_suffix)> {