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 requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pandas
defusedxml
lxml
5 changes: 3 additions & 2 deletions src/xml-validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import xml.etree.ElementTree as ET
from lxml import etree
from defusedxml.lxml import parse as defused_parse
Comment thread
daler91 marked this conversation as resolved.
import logging # Keep standard logging import for levels like logging.INFO
import re

Expand All @@ -28,11 +29,11 @@ def validate_against_xsd(xml_file, xsd_file):
"""
try:
# Parse the XSD schema
xmlschema_doc = etree.parse(xsd_file)
xmlschema_doc = defused_parse(xsd_file)
xmlschema = etree.XMLSchema(xmlschema_doc)

# Parse the XML file
xml_doc = etree.parse(xml_file)
xml_doc = defused_parse(xml_file)

# Validate
is_valid = xmlschema.validate(xml_doc)
Expand Down