Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xml2rfc/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def main():
help='generate utf8 output')
plain_options.add_argument('-v', '--verbose', action='store_true',
help='print extra information')
plain_options.add_argument('--lax-validation', action='store_true', default=False,
help='Treat schema validation errors as warnings (v3 writers)')


value_options = optionparser.add_argument_group('Generic Options with Values')
Expand Down
5 changes: 3 additions & 2 deletions xml2rfc/writers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
'info': False,
'info_base_url': 'https://www.rfc-editor.org/info/',
'inline_version_info': True,
'lax_validation': False,
'legacy': False,
'legacy_date_format': False,
'legacy_list_symbols': False,
Expand Down Expand Up @@ -2158,7 +2159,7 @@ def validate_before(self, e, p):
version = self.root.get('version', '3')
if version not in ['3', ]:
self.die(self.root, 'Expected <rfc> version="3", but found "%s"' % version)
if not self.validate('before'):
if not self.validate('before', warn=self.options.lax_validation):
self.note(None, "Schema validation failed for input document")

self.validate_draft_name()
Expand Down Expand Up @@ -2186,7 +2187,7 @@ def validate_after(self, e, p):
attrib = copy.deepcopy(e.attrib)
e.attrib.clear()
#
if not self.validate('after', warn=True):
if not self.validate('after', warn=self.options.lax_validation):
self.note(None, "Schema validation failed for input document")
else:
self.root.set('version', '3')
Expand Down
8 changes: 5 additions & 3 deletions xml2rfc/writers/preptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ def ol_add_counter(self, e, p):
# of the "target" attribute with no other adornment. Issue a
# warning if the "derivedContent" attribute already exists and has a
# different value from what was being filled in.
def build_derived_content(self, e):
def build_derived_content(self, e, lax_validation=False):
def split_pn(t, pn):
if pn is None:
self.die(e, "Expected to find a pn= attribute on <%s anchor='%s'> when processing <xref>, but found none" % (t.tag, t.get('anchor')), trace=True)
Expand All @@ -1554,7 +1554,9 @@ def get_name(t):
t = self.root.find('.//*[@pn="%s"]'%(target, ))
if t is None:
t = self.root.find('.//*[@slugifiedName="%s"]'%(target, ))
if t is None:
if t is None and lax_validation:
return e, "[PLACEHOLDER: %s]" % target
elif t is None:
self.die(e, "Found no element to match the <xref> target attribute '%s'" % (target, ))
#
p = t
Expand Down Expand Up @@ -1636,7 +1638,7 @@ def get_name(t):
def element_xref(self, e, p):
section = e.get('section')
relative = e.get('relative')
t, content = self.build_derived_content(e)
t, content = self.build_derived_content(e, lax_validation=self.options.lax_validation)
is_toc = p.get('pn', '').startswith('section-toc')
if not (section or relative):
attr = e.get('derivedContent')
Expand Down
Loading