DIY Schema Validation for Workmanlike ONIXDIY Schema Validation for Workmanlike ONIX
NOTE: This is dated documentation that has been superseded by much better EDItEUR documentation available at:
https://www.editeur.org/93/Release-3.0-Downloads/#How%20to
Mac specific:
https://www.editeur.org/files/ONIX%203/APPNOTE%20Validating%20ONIX%203.0%20files%20Mac%20edition.pdf
Windows specific
https://www.editeur.org/files/ONIX%203/APPNOTE%20Validating%20ONIX%203.0%20files%20PC%20edition.pdf
and a recording based on the Mac version but usable for Windows.
The information below may be of interest. There is no fundamental difference, as a procedure, between validating ONIX 2.1 and ONIX 3.0 except in the sense the actual XSD schemas are completely distinct, but the following is focused on 2.1 and doesn't include any information on EDItEUR's strict schema for ONIX 3.0 which is an excellent tool for ensuring your ONIX follows best practices.
...
You can't really understand anything done in XML unless you know how to do a proper XML validation of the file. For validation you need three things:
...
Locally Installing your files
Unitl Until recently EDItEUR supported ONIX 2.1 in a way that allowed you to do a standard DTD validation over the internet using files stored on the Editeur's server. That put a huge demand on Editeur's bandwidth and resources, so they've long asked all users install their reference files locally. As noted above, they have now gleefully taken away that option. ONIX 3.0 has never offered it. So like the change to Schemas from DTDs, local file installation is now just a normal part of the ONIX 2.1 and 3.0 world.
...
XML Nanny is excellent, simple software but some users have reported a line limit on XML Nanny where the software reports an error at line 65,535 when the actual error is many lines further down the file. It appears that citation is accurate – an error exists – but the line reporting stops working. If XML Nanny reports the file is fine, it is. It's only if it reports an error after line 65,535 that this crops up. On the assumption working solution to an issue is better than nothing and that you might have access to a PC, if you think you've encountered this issue and need a workaround try ONIX file splitter:
It's excellent software and reliably splits any size of ONIX file of either version, into same sized pieces which can be individually validated if you think you've run into this issue.
Linux and MAC
xmllint comes installed in most Linux versions and on many Macs as well. It's a command line XML parser which means you'll need to write small scripts to do validations. I'm not going to illustrate any more than the below (and don't use this unless you're more comfortable using command line tools than me), but this example is intended for a Mac, with the username "Bob" with a folder called "schema" on his "Desktop", containing (in this case) the ONIX 2.1 reference schema "ONIX_BookProduct_Release2.1_reference.xsd", The Desktop contains an ONIX file "TestOnix.xml" which has been set up for schema as noted below.
Note that there are some instructions in the "Reference or Short Tag" section below on how to confirm the file location on a MAC – you have to be absolutely right in your location or it doesn't work. And you need to understand the difference between Reference or Short tags as well. All that is discussed below in more detail.
This worked for me using Terminal:
| Code Block |
|---|
xmllint --schema /Users/Bob/Desktop/schema/ONIX_BookProduct_Release2.1_reference.xsd /Users/Bob/Desktop/TestOnix.xml |
You can find a full listing of commands here:
Java
Java based programs should workon any system but are seldom free. I'll illustrate oXygen as it's often recommended for working with ePub. It's expensive but you can get it on a 30 day trial. Any of the versions Editor / Developer / Author will work for validation.
...
The are lots more possible tools out there, but to use any of them you'll need to have the actual ONIX documents:
...
Note that it has two distinct declarations, the first invoking the .dtd, and a second one that cites the .xsd file.
Have a look at the original declaration – particularly the first line:
...