Join Jim Maivald for an in-depth discussion in this video Importing XML into the completed product sheet, part of InDesign CS5: Dynamic Publishing Workflows in XML.
- View Offline
The data has been exported to XML. The layout is structured. All that's left to do is to import the XML. But this file isn't exactly like the previous projects. In this file we have four distinctly separate XML structures. They are identical in construction, but the data in each layout will be unique. One section is for Shrubs, another for Container Plants, another for Perennials, and so on. We can't simply select the root element as in previous exercises to import the data. Instead we have to use a different technique, which I like to call targeted XML import.
Instead of importing the XML that's built for the whole structure, we are going to import XML that's designed specifically for one node of the structure at a time. Let's see how it works. Select the first node, which should be tagged for the Shrubs section. Go ahead and import the XML. Select the shrubs XML. Go ahead and choose the top three options. Clone repeating text, Only import elements that match our structure, and Do not import the contents of the whitespace. Go ahead and click OK. Cool! The XML only appears in one of the structured frames.
Go ahead and repeat that step now with each of the nodes. InDesign remembers the option you chose last time in the dialog. All you have to do is click OK. Two down, two to go. And finally, the Cacti. Everything is still the same. Go ahead and click OK. In less than 10 minutes we completely turned around this entire project. A project that used to take over a week. XML can do this and much, much more.
Just to tease you, I created an alternate layout to the one we just finished. I was curious at how far I could automate this project. Let's take a look at the results. This catalog layout is very similar to the previous one, but there are a couple of simple differences. You may notice that the margins are slightly different and the section intros are missing. If you click on the text frames in the layout, you'll see that they are linked. In the database, you may have noticed that each record included a field that stored both the section heading and the introductory text. This allows you to pull the data out of the file in any way, but still provide these essential elements.
For this workflow, instead of creating a structured layout, we're going to employ the power of XSLT to create everything we need. I created an XSLT file that will automatically select and group the products, as well as insert the section headings, and the intro text all at once. If you're interested in learning how the XSLT actually works, I fully commented the structure of this XSLT. Let's see how it works. Go ahead and select the root element as before and import the XML. I exported all the data from Access into one file.
Go ahead and click Open, and let's choose the XSLT from the project folder. That's all the options we need to check. Go ahead and click OK. Whenever you use a sorting command in an XSLT, InDesign will always display this warning dialog, but the sorting still takes place so just click OK. Wow! With one click we were able to create, not just one section, but all four sections of the catalog. Not every project will be this simple, but just think of the possibilities.
- Understanding XML terminology
- Identifying XML elements, attributes, and comments
- Adding, moving, and deleting elements
- Tagging and styling
- Creating tables with XML
- Building frame and flow layouts
- Ordering with XSLT
- Using the Document Type Definition in an XML workflow