Exporting XML from onCourse
Advanced tricks and tips
You’ve seen how easy it can be to export course information from onCourse and into Indesign. Now we’ll go into a little more depth with how to customise the output and create any type of publication you can dream of.
Exporting the classes you need
Your publication will only be as good as your data. Make sure you have entered information in the brochure description fields for your courses (and maybe also classes if there are specific notes there). Ensure they have the correct sessions, prices and other information. Now open the class list view and perform a search to find the classes you want. Perhaps you will choose a a subject or select classes by date, price or anything else you can think of. Now highlight the records you wish to export. [control A] or [Apple A] will help if you want to export all the classes you found. You might like to deselect specific classes from your list because they don’t require advertising or you haven’t confirmed that it will proceed. When you are done, choose “export classes as XML” from the cog wheel icon in the bottom right.
Transforming the XML using XSLT (optional)
If you have a publication you produce repeatedly you might like to automate the process of getting the text into the right format. XSLT is a technology which transforms XML according to a set of rules. Don’t be overwhelmed by the acronyms: the process is simple enough. XML is the format of the data you just exported from onCourse - a set of tags identify each element in the data. A <course> or <startDate> is a marker which let’s you know what the information represents. There is no styling or design in the XML, it represents pure data with no prettiness. The XML from onCourse has a schema advanced users might like to see here
You can create an XSL file which is a set of instructions on how to style that XML. The output is often more XML, but could be a web page, RSS feed, PDF file or even a Word document. XSL instructions can be used to create almost any type of document imaginable. Any material which comes from a database can be treated in this way - for example, the printed White Pages telephone directory is produced in this manner. A sample XSL file is available on this page for you to look at and modify for your needs.
Some things you can do with XSL:
- format date and time (eg. “2 Jan 2008”)
- reorder elements
- add extra text (eg. “
8 2 ” becomes “8 sessions of 2 hrs”) - remove elements (the sample XSL removes all the session information)
Writing XSL
Writing an XSL file from scratch can be tricky if you’ve never done it before. ish is able to offer services to produce a file for your needs or you may be able to find a local specialist. If you want something simple, customise the sample file attached to this page. We recommend Oxygen for any serious editing and testing of XSL files.
Running your XSL transform
If you write an XSL using version 1 of the specification, then Indesign can process it directly while you import the XML. However the file found below uses the more advanced features of XSL 2.0 and Indesign CS3 does not at this time support that. Fear not, free third party tools can be used to process the file and get the output you want.
A good free XSL processor which runs on all platforms is called Kernow Follow the instructions on the web site to install the tool on your machine. Then run it and go to the ’Single File’ tab. Choose the onCourse XML export file as the “XML file”. Choose your stylesheet and then press Run. It will produce formatted output.
Importing into Indesign
Whether or not you processed your XML with XSL, you can now import it into Indesign. Adobe have a helpful document and another with some example XSL. The process is simple:
- File -> Import XML…
- Choose your XML file
- If you are having Indesign process an XSL 1.0 file you can now choose it
- Ticking “Link” will keep the Indesign document linked to your source XML so that changes to the XML flow through
- The structure of the data will now appear in the left column. You can drag any element into a text box in your layout and have the text automatically flow through.
- Use the “map tags to styles…” menu item to map the tags against your paragraph and character style sheets. Once this is done you can save the mapping so that next time you create this document with fresh data all the styles are linked quickly and simply.
Summary
XML and XSL can be a little daunting at first, but they offer the promise for huge savings in efforts particularly when preparing longer course guides and documents.- CoursesExample.xsl (3 KB)
- Login to post comments




