Schema validation error since Oct 1st
Hi, just a friendly reminder. If you see a new error message like XMLSchemaParseError: Opening and ending tag mismatch: br line 30 and h1, line 31, column 128 then it's not your fault. You can blame it on the US Congress. The Library Of Congress has shut down so XSD schema links like http://www.loc.gov/standards/xlink/xlink.xsd redirect to a HTTP page. In order to fix the issue in your code you have to implement a resolver. Example: from lxml import etree class XSDResolver(etree.Resolver): """See http://lxml.de/resolvers.html#uri-resolvers """ xsd_map = { 'http://www.loc.gov/standards/xlink/xlink.xsd': '/path/to/xlink.xsd', } def resolve(self, url, id, context): xsdfile = self.xsd_map.get(url) if xsdfile: return self.resolve_filename(xsdfile, context) # use next resolver return None parser = etree.XMLParser() parser.resolvers.add(XSDResolver()) tree = etree.parse(xmlfile, parser) HTH Christian
participants (1)
-
Christian Heimes