diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/Main.cpp | 2 | ||||
-rw-r--r-- | src/formats/osml/OsmlParser.cpp | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/cli/Main.cpp b/src/cli/Main.cpp index 2658851..cbe7578 100644 --- a/src/cli/Main.cpp +++ b/src/cli/Main.cpp @@ -236,7 +236,7 @@ int main(int argc, char **argv) } // now all preparation is done and we can parse the input document. - Rooted<Node> docNode = context.import(inputPath, "text/vnd.ousia.oxd", "", + Rooted<Node> docNode = context.import(inputPath, "", "", {&RttiTypes::Document}); if (logger.hasError() || docNode == nullptr) { logger.fatalError("Errors occured while parsing the document"); diff --git a/src/formats/osml/OsmlParser.cpp b/src/formats/osml/OsmlParser.cpp index 87f4c00..519a2d8 100644 --- a/src/formats/osml/OsmlParser.cpp +++ b/src/formats/osml/OsmlParser.cpp @@ -64,13 +64,27 @@ public: */ void parse() { + // Flag set to true if a "document" element needs to be created + bool needsDocument = true; while (true) { OsmlStreamParser::State state = parser.parse(); switch (state) { - case OsmlStreamParser::State::COMMAND: + case OsmlStreamParser::State::COMMAND: { + // Implicitly create a "document" element if the first + // command is not any other top-level command + if (needsDocument) { + const std::string &cmd = + parser.getCommandName().asString(); + if (cmd != "typesystem" && cmd != "document" && + cmd != "domain") { + stack.command("document", Variant::mapType{}); + } + needsDocument = false; + } stack.command(parser.getCommandName(), parser.getCommandArguments().asMap()); break; + } case OsmlStreamParser::State::DATA: stack.data(parser.getData()); break; |