5.4. Validation of Foods XML files

Pantry automatically validates Foods XML files for you.[15] To see the DTD that Pantry uses for this purpose, run pantry --dump foodsDTD. 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 foods.xml master). Pantry will give you an error message if you try to use a file that large. One way to use them 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.