Creating multiple paragraphs of text within a single ONIX data element is a notoriously tricky feat, but there’s really nothing worse when you’re looking at the synopsis of a book on a retailer’s page than a big block of text with the description, reviews and author bio all bunched together.
Luckily, using HTML markup can help you avoid the eyesore of a solid block of text. EDItEUR, the international group that coordinates development of the standards infrastructure for ecommerce messaging standards, has provided some recommendations for using HTML markup to break up blocks of text.
1. ‘Escape’ every “<” character in the HTML markup with “& l t ;”
This ensures a < character is not taken for the opening of an ONIX tag.
The tags highlighted in pink all have their < characters ‘escaped’. Note that the first paragraph of text (which ends with the word ‘novelists’) has no < /p > tag, so this is HTML rather than XHTML, and you need to use the textformat attribute code 02 (highlighted in green).
2. Surround your HTML with CDATA tags
CDATA tags prevent the HTML from causing errors if your trading partner validates the ONIX against the DTD or XSD, without having to ‘escape’ the < characters. The down side of this is that the validity of the HTML markup cannot be checked. Note: This is the only legitimate use for CDATA within ONIX.
Method 1 and Method 2 can never be used in conjunction: pick one method, and use it consistently.
3. The best option of all is to switch to using XHTML
It’s just like HTML, except that all the tags must be lower case and properly closed. Also, in HTML, the “< /p>” tag is optional at the end of a paragraph, whereas in XHTML, it is mandatory.
The tag highlighted in pink – the closing tag of the first paragraph – is the only tag that needs to be added to transform the HTML from the first two examples into XHTML. And the XHTML can then be used within the ONIX without any further modifications. Note the textformat attribute code 05 indicates XHTML.
So there you have it, three easy methods for creating separate paragraphs within an ONIX element. Remember, XHTML is #1, but if it’s not feasible for you to make the switch from plain old HTML to the superior XHTML right now, either of the first two methods will also suffice.