dtd_scanner
dtd_scanner validates each article's harvested XML against the DTD (Document Type Definition) it declares, similar in role to relaxng_scanner but for DTD-based schemas instead of RelaxNG. For each article, it extracts the DTD's public/system identifiers from the XML file's doctype declaration, copies the XML into a local DTD-specific working folder, and attempts to parse it with DTD validation enabled. Valid articles proceed to the next pipeline stage; invalid, malformed, or DTD-info-missing articles are logged to dedicated CSV reports and routed into a stop folder.
Working
- For each article, it checks whether a
temp_/dtd_scanner_/stop_- prefixed folder already exists (viacommon/functions.py'sprocessfolder_check) and skips the article if so. - If thats not the case, it locates the latest publisher-module folder for the article (by taking the most recent date suffix among the article's subfolders whose name starts with the previous module's name), and expects to find a
metadata-article.jsonand anxml/folder inside it. - Then, it parses the XML's doctype to get its DTD public identifier and system identifier (file name). If either is missing, the article is logged to
log_articles_dtd-info_missing.csvand the temp folder is renamed to a stop folder. - If the DTD identifiers are present, a working copy of the XML is placed into a local per-DTD folder (
<data_root_temp>/XML-Schemadateien/<dtd_name>---<dtd_file>/), and validated against the DTD file expected to already exist there. Missing DTD files are logged tolog_dtd_missing.csv. - On successful validation: the source folder's content is copied into the temp folder, a
history.csventry is written, the temp folder is renamed to the permanentdtd_scanner_<date>name, the previous module's content is deleted, and aprocessed-by-module-dtd_scannermarker is created. - On failed validation: logged to
log_articles_dtd-invalid.csv, an error.txtfile is written into the temp folder, and it's renamed to a stop folder instead. - At the end of a run, several CSV report files have their duplicate rows removed, and a set of summary log statements report totals (well-formed/malformed articles, DTD-valid/invalid articles, missing DTDs).