-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.cpp
70 lines (53 loc) · 1.83 KB
/
validate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/***************************************************************************
The Base Framework
A framework for developing platform independent applications
See COPYRIGHT.txt for details.
This framework is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For the licensing terms refer to the file 'LICENSE'.
***************************************************************************/
#include <base/Application.h>
#include <base/string/FormatOutputStream.h>
#include <base/xml/DOMImplementation.h>
using namespace com::azure::dev::base;
class ValidateApplication : public Application {
private:
static const unsigned int MAJOR_VERSION = 1;
static const unsigned int MINOR_VERSION = 0;
public:
ValidateApplication()
: Application("validate")
{
}
void main()
{
fout << getFormalName() << " version "
<< MAJOR_VERSION << '.' << MINOR_VERSION << EOL
<< "The Base Framework (Test Suite)" << EOL
<< ENDL;
Array<String> arguments = getArguments();
if (arguments.getSize() != 1) {
fout << getFormalName() << " uri" << ENDL;
return; // stop
}
// TAG: need option --wellformed
const String sourceURI = arguments[0];
DOMImplementation dom;
DOMImplementation::Mode mode =
true ? DOMImplementation::VALIDATING : DOMImplementation::PARSING;
try {
Document document = dom.createFromURI(sourceURI, mode);
} catch (DOMException& e) {
fout << "Error: " << e << ENDL;
setExitCode(EXIT_CODE_ERROR);
return;
}
if (true) {
fout << "Document is valid" << ENDL;
} else {
fout << "Document is well-formed" << ENDL;
}
}
};
APPLICATION_STUB(ValidateApplication);