For the purist, those who want their XML validation without the added benefits of what some programmer thinks would improve their ONIX file, there is a lovely generic XML software product called XML Notepad 2007. It’s free and written by a Microsoft programmer, Chris Lovett, so the freeware is from a safe source, it’s easy to set-up for a schema validation and robust with files as large as 20,000 records. The only problem is that you’ll need to use a file with its XML declaration information set up for a schema validation rather than using the normal ONIX declaration. That just means replacing the first few lines of the ONIX file with a different script—a simple cut and paste that only takes a few seconds. Just be sure to use the correct ONIX declaration on the file you send to trading partners.
The software requires that you have.NET Frameworks v2.0 or above installed (you’ll likely have it already on your computer, but it’s another Microsoft product) and you can download XML Notepad here:
http://www.codeplex.com/xmlnotepad
Just follow the links to the installer.
Getting the ONIX Schema
You’ll need is the ONIX Schema on your computer, which is available from www.editeur.org:
- Navigate through Standards to ONIX for Books, Previous releases (not ONIX 3.0)
- Scroll down to “Download Release 2.1 XML Schema” and click on it.
- Click on the “Release 2.1 (revision XX) XML Schema” and save the zip to your hard drive.
Unpacking the zip will give you a directory with 7 files in it, 6 xsd ‘schema’ files and a ‘read me’. You’ll need to put a location reference to these files into your schema, so make it easy on yourself and store this on your computer in an easily named location—avoid spaces in your directory names (spaces can confuse the XML software’s ability to find the file). As an example, if you were to create a directory in your top level C drive named XML with a subdirectory XSD and put the contents of the zip there, then naming the local file reference would not only be easy but have a long tradition behind it:
C:\XML\XSD\
However you choose to name the location put the 7 files into that location.
The schema file ONIX_BookProduct_CodeLists.xsd includes the ONIX codes, so every time the code list is updated, this file needs to be updated as well. New code lists are announced and listed by BookNet but if you add a new code to your ONIX and your file fails your validation process an outdated XSDs file might be the problem.
Create a Schema-Specific File
The last hurdle is creating a schema specific file with your ONIX in it. The ONIX file you send to your trading partners has to have the “declaration”—the first lines before the Header tags—as defined by the ONIX for Books XML Message Specification. In order to schema validate using XML Notepad (and other XML software) you’ll need to replace that declaration with another one.
While you can modify your ONIX file with a new declaration, what I find easier is to create a file just for schema validation and then to copy the ONIX data section into it. Create a file, say: “schema.xml,” with either the Reference or Short tag declarations as below. And then copy and paste the ONIX file in using everything from the tag < Header> (Reference) or < header> (Short) to the bottom of the ONIX file (including the < ONIXMessage> or < ONIXmessage> tag).
Or alternatively, you can copy and paste a declaration from below into your ONIX file. You just have to be sure to replace it with the correct ONIX Message declaration before you send the file to your trading partners.
But one way or another, everything from the first line < ?xml version… through to < ONIXMessage> (for reference tag files) or < ONIXmessage> (for short tag files), such as in this example:
< ?xml version=”1.0” encoding=”utf-8”?>
< !DOCTYPE ONIXMessage SYSTEM “http://www.editeur.org/onix/2.1/02/reference/onix-international.dtd”>
< ONIXMessage>
needs to be replaced with the following:
For ONIX files using Reference Tags:
< ?xml version=”1.0” encoding=”utf-8”?>
< ONIXMessage refname=”ONIXMessage” shortname=”ONIXmessage” release=”2.1”
xmlns=”http://www.editeur.org/onix/2.1/reference”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.editeur.org/onix/2.1/reference
C:\XML\XSD\ONIX_BookProduct_Release2.1_reference.xsd”>
For ONIX files using Short Tags:
< ?xml version=”1.0” encoding=” utf-8”?>
< ONIXmessage refname=”ONIXMessage” shortname=”ONIXmessage” release=”2.1”
xmlns=”http://www.editeur.org/onix/2.1/short”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.editeur.org/onix/2.1/short
C:\XML\XSD\ONIX_BookProduct_Release2.1_short.xsd”>
Note that the last line in the declaration contains the “local address” on your computer and one of the Schema files you downloaded from Editeur.org. So unless you’ve used the suggested directory naming proposed above you’ll need to modify the above script to use the local computer address you used. Note also that if there are spaces in the directory name (and possibly long directory names) that the address may not be read properly by the XML software. This is one of the most likely things to go wrong—keeping it simple and direct makes your life easier.
That’s it. Save the file (always save the file as the software works with the last saved version and won’t include unsaved changes) with your data and the new declarations.
Setting up to use Schemas using XML Notepad
Start up XML Notepad 2007. You’ll need to let the software know where to find the schema by creating an internal link to the XSD schema files from Editeur. So:
- Top menu bar: Click on View
- From the dropdown: Click on Schema
- From the dialog box: Click on the box with the ellipse (three dots) at the far right
This opens a standard Windows file finding user interface—use it to navigate to where the schemas are stored and select:
For Reference tags: ONIX_BookProduct_Release2.1_reference.xsd
For Short tags: ONIX_BookProduct_Release2.1_short.xsd
(You can do this step twice and put both reference and short links here. The program will work fine if you do, but it’s only necessary if you use both short and reference tag files.)
Note: Whenever you first start XML Notepad you’ll need to let it know where the local schemas are—it’s just a matter of opening the Schema dialog and clicking “OK.”
Your First Validation using XML Notepad
Using XML Notepad go to its top menu bar: Click on File / Open and from the dropdown choose the file you created using the schema declaration and your ONIX data in it and open it.
Assuming it opens (if not, skip back to previous blog posts on File Cleaning), in the upper left, you’ll find a tree that corresponds to the file’s XML structure—the composite and tag names are displayed.
In the upper right is the data within those tags, and on the bottom half—the Error List which may (or may not) be displaying errors.
First: Did you open the Schema dialogue and click OK? Are you sure? XML Notepad will display errors until you confirm the schema that it should use. So, just to be sure go to the top menu bar: Click on View, Choose Schema, (and assuming the ONIX schemas are there as described in the previous section) Click on OK.
In the error section double click on one of the errors. If you have a large file it may take a while to respond, but it will take you directly to the error identified. If you have no idea why it’s a problem (and why would you?) I’ll try to put some advice together in future blogs, but the problem will either be a violation of the XML Standard or a violation of the ONIX Standard.
There’s a webinar available on this
http://connectpro95248216.acrobat.com/p33362696/
It’s a little rough, but we’re just learning the software (and truth be told, I’m not at Michael Tamblyn’s level of presentation), but if you find this sort of webinar helpful let us know and we’ll try to do more.
For your convenience here here are two files set up for Schema validation. Limitations on our website prevent me from using files with a .xml extension, so you’ll have to change the file from .txt to .xml. There are two, one for Reference Tags and one for Short Tags—if your tags are largely in English then it’s Reference and if the tags are largely a character plus 3 digit codes then it’s Short: