Using an XML catalog with Python's lxml?
问题 Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a document’s DTD. 回答1: You can add the catalog to the XML_CATALOG_FILES environment variable: os.environ['XML_CATALOG_FILES'] = 'file:///to/my/catalog.xml' See this thread. Note that entries in XML_CATALOG_FILES are space-separated URLs. You can use Python's pathname2url and urljoin (with file: ) to