32
32
bare_latin_tags , unicode_attributes , downcode , downcode_punctuation )
33
33
from xml2rfc .utils import namespaces , find_duplicate_ids , slugify
34
34
35
+
36
+ DEADLY_ERRORS = [
37
+ 'Element svg has extra content: script' ,
38
+ 'Did not expect element script there' ,
39
+ ]
40
+
35
41
default_silenced_messages = [
36
42
# ".*[Pp]ostal address",
37
43
]
@@ -2136,6 +2142,15 @@ def indent(e, i):
2136
2142
indent (e , 0 )
2137
2143
e .tail = None
2138
2144
2145
+ def deadly_error (self , error ):
2146
+ # errors that xml2rfc must not allow to continue
2147
+
2148
+ if error .message in DEADLY_ERRORS :
2149
+ if self .options .verbose :
2150
+ msg = "%s(%s): Error: Can not continue further with error: %s" % (self .xmlrfc .source , error .line , error .message )
2151
+ self .log (msg )
2152
+ return True
2153
+
2139
2154
def validate (self , when = '' , warn = False ):
2140
2155
# Note: Our schema doesn't permit xi:include elements, so the document
2141
2156
# must have had XInclude processing done before calling validate()
@@ -2164,11 +2179,14 @@ def validate(self, when='', warn=False):
2164
2179
"higher for better error messages." % ('.' .join (str (v ) for v in lxmlver ), ))
2165
2180
# These warnings are occasionally incorrect -- disable this
2166
2181
# output for now:
2182
+ deadly = False
2167
2183
if hasattr (e , 'error_log' ):
2168
2184
for error in e .error_log :
2169
2185
path = getattr (error , 'path' , '' )
2170
2186
msg = "%s(%s): %s: %s, at %s" % (self .xmlrfc .source , error .line , error .level_name .title (), error .message , path )
2171
2187
self .log (msg )
2188
+ if not deadly :
2189
+ deadly = self .deadly_error (error )
2172
2190
if error .message .startswith ("Did not expect text" ):
2173
2191
items = self .tree .xpath (error .path + '/text()' )
2174
2192
for item in items :
@@ -2179,7 +2197,7 @@ def validate(self, when='', warn=False):
2179
2197
2180
2198
else :
2181
2199
log .warn ('\n Invalid document: %s' % (e ,))
2182
- if warn :
2200
+ if warn and not deadly :
2183
2201
self .warn (self .root , 'Invalid document%s.' % (when , ))
2184
2202
return False
2185
2203
else :
0 commit comments