Let's say I want to be able to validate that a 50GB+ XML file conforms to a given XSD. I could use
DOMDocument::load & DOMDocument::schemaValidate
but that will take all of time on loading and will generally exhaust all available memory for me. Is there any way to feed an XSD to a SAX or any other type of stream processor and have it verify that all is well?
The DOMDocument::validate() function is an inbuilt function in PHP which is used to validate the document based on its DTD (Document Type Definition). DTD defines the rules or structure to be followed by the XML file and if a XML document doesn't follows this format then this function will return false.
You can validate your XML documents against XML schemas only; validation against DTDs is not supported. However, although you cannot validate against DTDs, you can insert documents that contain a DOCTYPE or that refer to DTDs.
The WSRR web user interface validates each definition file when starting, and when new or updated definition files are loaded. This is done according to the definition XML Schema Definition (XSD).
You may use XMLReader:
$reader = new XMLReader();
$reader->open('xmlfile.xml');
$reader->setSchema('schemafile.xsd');
while($reader->read());
$reader->close();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With