1
2
3
4
5
6 #include <sngxml/xml/XmlParserInterface.hpp>
7 #include <sngxml/xml/XmlParser.hpp>
8 #include <soulng/lexer/TrivialLexer.hpp>
9 #include <soulng/lexer/XmlParsingLog.hpp>
10 #include <soulng/util/Unicode.hpp>
11 #include <soulng/util/MappedInputFile.hpp>
12 #include <iostream>
13
14 namespace sngxml { namespace xml {
15
16 using namespace soulng::util;
17 using namespace soulng::unicode;
18
19 void ParseXmlFile(const std::string& xmlFileName, XmlContentHandler* contentHandler)
20 {
21 ParseXmlFile(xmlFileName, contentHandler, Flags::none);
22 }
23
24 void ParseXmlFile(const std::string& xmlFileName, XmlContentHandler* contentHandler, Flags flags)
25 {
26 std::string xmlContent = ReadFile(xmlFileName);
27 ParseXmlContent(xmlContent, xmlFileName, contentHandler, flags);
28 }
29
30 void ParseXmlContent(const std::string& xmlContent, const std::string& systemId, XmlContentHandler* contentHandler)
31 {
32 ParseXmlContent(ToUtf32(xmlContent), systemId, contentHandler, Flags::none);
33 }
34
35 void ParseXmlContent(const std::string& xmlContent, const std::string& systemId, XmlContentHandler* contentHandler, Flags flags)
36 {
37 ParseXmlContent(ToUtf32(xmlContent), systemId, contentHandler, flags);
38 }
39
40 void ParseXmlContent(const std::u32string& xmlContent, const std::string& systemId, XmlContentHandler* contentHandler)
41 {
42 ParseXmlContent(xmlContent, systemId, contentHandler, Flags::none);
43 }
44
45 void ParseXmlContent(const std::u32string& xmlContent, const std::string& systemId, XmlContentHandler* contentHandler, Flags flags)
46 {
47 soulng::lexer::XmlParsingLog debugLog(std::cerr);
48 TrivialLexer xmlLexer(xmlContent, systemId, 0);
49 if ((flags & Flags::debug) != Flags::none)
50 {
51 xmlLexer.SetLog(&debugLog);
52 }
53 XmlProcessor xmlProcessor(xmlLexer, contentHandler);
54 XmlParser::Parse(xmlLexer, &xmlProcessor);
55 }
56
57 } }