5.4. Validation of Pantry XML files
Prev | Chapter 5. Adding new foods and editing the nutrients or units of existing foods | Next

## 5.4. Validation of Pantry XML files

Pantry automatically validates Pantry XML files for you.[15] To see the DTD that Pantry uses for this purpose, run `pantry --dump pantryDTD`. You might, for instance, want to use this DTD to validate the XML yourself.

If any of your files do not validate, Pantry will print an error message along with the output of the validator. Study the output of the validator because it will usually help you fix the error.

The validator will often hang if the input file is very large. Therefore, Pantry will only validate files if they are below 300 kilobytes in size. It is unlikely that you will ever create XML files that large by hand, although you might have Pantry create an XML file that large (that's what you will get if you run, for example, `pantry --add pantry.xml master`). Pantry will give you an error message if you try to use a file that large. One way to use large files is to use the `--skip-valid`, which will turn off validation. This is of course a bad idea for files that you have edited by hand (because they might have errors that then will go unchecked) but skipping validation is fine for large files that were generated entirely by Pantry. Alternatively, you can use `--force-valid` to make Pantry validate all XML files, regardless of how large they are. This might cause Pantry to wait for an extremely long time for the validator to finish--the validator might even freeze if the file is extremely large.

[15] If your system has xmllint installed, that is what Pantry will use to validate files. If not, then Pantry will use a validator written in Python, which is slower but gets the job done. For best performance, ensure that your system has xmllint installed. Typically xmllint is part of the libxml2 package if you are using Linux.

Prev | Up | Next
5.3. Using Pantry XML files to edit units or nutrients of foods | Home | Chapter 6. Plain text Foods files, and choosing which type of Foods file to use