From 2da3efbf053e12861c9184c3f8bd014fae245773 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 17 Feb 2015 18:30:12 +0100 Subject: Fixed creating a document where no document should be created (I actually thought of this bug before it occurred!) --- src/formats/osml/OsmlParser.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/formats/osml/OsmlParser.cpp') 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 + +#include + #include #include #include +#include #include "OsmlParser.hpp" #include "OsmlStreamParser.hpp" @@ -39,6 +43,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() == nullptr; while (true) { OsmlStreamParser::State state = parser.parse(); logger.setDefaultLocation(parser.getLocation()); -- cgit v1.2.3