-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathxmlvalidate
executable file
·33 lines (28 loc) · 903 Bytes
/
xmlvalidate
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
#!/usr/bin/env python2
# -*- coding: ISO-8859-1 -*-
#
# Copyright (C) 2003 by Frank Lübeck and Max Neunhöffer
#
import os, sys
sys.path = [os.path.join(sys.path[0], 'server')] + sys.path
from fmTools import Utils, XMLRewrite
if len(sys.argv) == 1:
print '''Usage: xmlvalidate [-w] file1 [file2] [...]
With -w option it is checked if the file is a well formed XML document.
'''
action = 'Validating'
if '-w' in sys.argv:
XMLRewrite.ValidatingParserConfig['NoNoDTDWarning'] = 1
XMLRewrite.ValidatingParserConfig['Validate'] = 0
action = 'Checking'
files = sys.argv[1:]
for fn in files:
if fn == '-w':
pass
elif not os.path.exists(fn):
Utils.Error('File '+fn+' does not exist.')
else:
Utils.Error(action+' file '+fn+' ...', prefix='')
t = XMLRewrite.Parse(config=XMLRewrite.ValidatingParserConfig, file=fn)
if t:
Utils.Error('Success!', prefix='')