summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-17 18:30:12 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-17 18:30:12 +0100
commit2da3efbf053e12861c9184c3f8bd014fae245773 (patch)
tree18dd5dcc5a39a7c14c129900d127fdea451da075 /src
parente3e4a43e677380b2c99f946ba74edd8c29b497d6 (diff)
Fixed creating a document where no document should be created (I actually thought of this bug before it occurred!)
Diffstat (limited to 'src')
-rw-r--r--src/formats/osml/OsmlParser.cpp12
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());