]> git.donarmstrong.com Git - flightcrew.git/blob - src/FlightCrew/Validators/Xhtml/SatisfiesXhtmlSchema.cpp
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / FlightCrew / Validators / Xhtml / SatisfiesXhtmlSchema.cpp
1 /************************************************************************\r
2 **\r
3 **  Copyright (C) 2010  Strahinja Markovic\r
4 **\r
5 **  This file is part of FlightCrew.\r
6 **\r
7 **  FlightCrew is free software: you can redistribute it and/or modify\r
8 **  it under the terms of the GNU Lesser General Public License as published\r
9 **  by the Free Software Foundation, either version 3 of the License, or\r
10 **  (at your option) any later version.\r
11 **\r
12 **  FlightCrew is distributed in the hope that it will be useful,\r
13 **  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 **  GNU Lesser General Public License for more details.\r
16 **\r
17 **  You should have received a copy of the GNU Lesser General Public License\r
18 **  along with FlightCrew.  If not, see <http://www.gnu.org/licenses/>.\r
19 **\r
20 *************************************************************************/\r
21 \r
22 #include <stdafx.h>\r
23 #include "SatisfiesXhtmlSchema.h"\r
24 #include "Misc/ErrorResultCollector.h"\r
25 #include <ToXercesStringConverter.h>\r
26 #include <XmlUtils.h>\r
27 #include <LocationAwareDOMParser.h>\r
28 #include <xercesc/sax/SAXException.hpp>\r
29 \r
30 namespace FlightCrew\r
31 {\r
32 \r
33 SatisfiesXhtmlSchema::SatisfiesXhtmlSchema()\r
34     :\r
35     m_Dtd( XHTML11_FLAT_DTD,\r
36            XHTML11_FLAT_DTD_LEN,\r
37            toX( XHTML11_FLAT_DTD_ID ) ),\r
38     m_OpsSchema( OPS201_XSD,\r
39                  OPS201_XSD_LEN,\r
40                  toX( OPS201_XSD_ID ) ),\r
41     m_OpsSwitchSchema( OPS_SWITCH_XSD, \r
42                        OPS_SWITCH_XSD_LEN,\r
43                        toX( OPS_SWITCH_XSD_ID ) ),\r
44     m_SvgSchema( SVG11_XSD, \r
45                  SVG11_XSD_LEN,  \r
46                  toX( SVG11_XSD_ID ) ),\r
47     m_XlinkSchema( XLINK_XSD, \r
48                    XLINK_XSD_LEN,\r
49                    toX( XLINK_XSD_ID ) ),\r
50     m_XmlSchema( XML_XSD, \r
51                  XML_XSD_LEN,\r
52                  toX( XML_XSD_ID ) )\r
53 {\r
54 \r
55 }\r
56 \r
57 \r
58 std::vector< Result > SatisfiesXhtmlSchema::ValidateFile( const fs::path &filepath )\r
59 {\r
60     std::string location = std::string( OPS201_XSD_NS )\r
61                            .append( " " )\r
62                            .append( OPS201_XSD_ID );\r
63 \r
64     std::vector< const xc::MemBufInputSource* > schemas;\r
65     schemas.push_back( &m_XmlSchema       );\r
66     schemas.push_back( &m_XlinkSchema     );\r
67     schemas.push_back( &m_SvgSchema       );\r
68     schemas.push_back( &m_OpsSwitchSchema );\r
69     schemas.push_back( &m_OpsSchema       );\r
70 \r
71     std::vector< const xc::MemBufInputSource* > dtds;\r
72     dtds.push_back( &m_Dtd );\r
73 \r
74     return ValidateAgainstSchema( filepath, location, schemas, dtds ); \r
75 }\r
76 \r
77 } //namespace FlightCrew\r