MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / validate_xml

Method validate_xml

pptx/ooxml/scripts/validation/base.py:127–154  ·  view source on GitHub ↗

Validate that all XML files are well-formed.

(self)

Source from the content-addressed store, hash-verified

125 raise NotImplementedError("Subclasses must implement the validate method")
126
127 def validate_xml(self):
128 """Validate that all XML files are well-formed."""
129 errors = []
130
131 for xml_file in self.xml_files:
132 try:
133 # Try to parse the XML file
134 lxml.etree.parse(str(xml_file))
135 except lxml.etree.XMLSyntaxError as e:
136 errors.append(
137 f" {xml_file.relative_to(self.unpacked_dir)}: "
138 f"Line {e.lineno}: {e.msg}"
139 )
140 except Exception as e:
141 errors.append(
142 f" {xml_file.relative_to(self.unpacked_dir)}: "
143 f"Unexpected error: {str(e)}"
144 )
145
146 if errors:
147 print(f"FAILED - Found {len(errors)} XML violations:")
148 for error in errors:
149 print(error)
150 return False
151 else:
152 if self.verbose:
153 print("PASSED - All XML files are well-formed")
154 return True
155
156 def validate_namespaces(self):
157 """Validate that namespace prefixes in Ignorable attributes are declared."""

Callers 2

validateMethod · 0.45
validateMethod · 0.45

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected