diff options
-rw-r--r-- | src/formats/osml/OsmlParser.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/formats/osml/OsmlParser.cpp b/src/formats/osml/OsmlParser.cpp index c77da09..a24f091 100644 --- a/src/formats/osml/OsmlParser.cpp +++ b/src/formats/osml/OsmlParser.cpp @@ -17,9 +17,13 @@ */ #include <core/common/Logger.hpp> + +#include <core/model/Document.hpp> + #include <core/parser/stack/GenericParserStates.hpp> #include <core/parser/stack/Stack.hpp> #include <core/parser/ParserContext.hpp> +#include <core/parser/ParserScope.hpp> #include "OsmlParser.hpp" #include "OsmlStreamParser.hpp" @@ -40,6 +44,11 @@ private: Logger &logger; /** + * Reference at the parser context. + */ + ParserContext &ctx; + + /** * OsmlStreamParser instance responsible for converting the input stream * into a series of osml events that are relayed to the Stack class. */ @@ -62,6 +71,7 @@ public: */ OsmlParserImplementation(CharReader &reader, ParserContext &ctx) : logger(ctx.getLogger()), + ctx(ctx), parser(reader, logger), stack(ctx, GenericParserStates) { @@ -73,7 +83,7 @@ public: void parse() { // Flag set to true if a "document" element needs to be created - bool needsDocument = true; + bool needsDocument = ctx.getScope().select<Document>() == nullptr; while (true) { OsmlStreamParser::State state = parser.parse(); logger.setDefaultLocation(parser.getLocation()); |