InDesign XML Strategies and Tutorial with Template

result3

This InDesign XML tutorial describes a sample end-to-end workflow for XML pagination in Adobe InDesign.

The free project template is available on the sidebar to the right.

Note: XML-based InDesign workflows allow for close control over a document’s graphical elements and enable you to automate almost any kind of layout. But XML has a steep learning curve, and a dedicated team can be required to establish, maintain, and troubleshoot the logic behind even relatively simple operations.

Pagination offers solutions to overcome conversion issues.

Check out our cloud database publishing solution.

banner2-pagina-templates

1. Editing the InDesign template

Let’s start by taking a brief look at the XML file structure. In this tutorial we want to merge a list of cars. Each car has attributes that need to be imported (‘BRAND’, “CAR_MODEL’, ‘TYPE’ etc.) as well as an image.

xml file

2. Configuring the image fields

InDesign will only include an image field if a href attribute is added as an XML element. A href attribute requires an image’s relative or absolute image URL.

Examples of absolute URLs include:

On a Windows system – href = “file:///C:/Images/car.psd”
On a Mac system – href = “file:///Users/user-name/Documents/car.psd”

Relative URL paths are taken from the XML file’s save location. Example of relative URLs include:

href = “file:///car.psd” (when the image and XML file share a folder)
href = “file:///Images/car.psd”
href = “file:///…/Images/car.psd”

All URLs must include the string ‘file:///’ as a prefix.

2.1 Adding href attributes

Adding href attributes to every image can take a lot of time.

banner-4-pagina-templates

3. Two InDesign tools

The next step involves two InDesign tools. The first is the Structure panel. This panel contains all elements from our XML content. It also allows us to add, edit and delete elements and attributes to/from the existing structure. Access the Structure panel through View -> Structure -> Show Structure.

structure pane

The second tool is the Tags panel. This panel contains a list of tags that are used for assigning XML elements that should be imported to the InDesign document. We can assign tags to texts and image placeholders. Access the Tags panel through Window -> Utilities -> Tags.

tag panel

4. Setting up the InDesign template

We start a new InDesign document through File -> Document. For this tutorial we’ll uncheck ‘Facing Pages’, check ‘Primary Text Frame’ and select two columns.

new document

We can now open the master page and customize it with our project layout and header/footer objects.

master page layout

5. XML Import

Return to the document’s first page and open the Structure panel. Click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu).

import xml command

This option will open a new dialog box. Choose our XML file and check the ‘Show XML Import Options’ and ‘Merge Content’ options before opening it.

XML - show import options

Uncheck all boxes in the next dialog box and then press ‘OK’.

XML options dialog

The XML file has now been imported into our document. The document structure has been populated like the XML file, and the Tags panel has also been populated with the XML file’s corresponding elements.

xml import tools - example

We only need one car element for the mapping stage. Delete the rest from the Structure panel by selecting them, right clicking and pressing ‘Delete’.

delete tags

5.1 Document structure and Tags panel

Document structure and the Tags panel can be quite intimidating.

banner-templates

6. Mapping the XML structure

We map the imported XML file by dragging and dropping elements from the Structure panel into the document or assigning tags to the document from the Tags panel.

Start by assigning the car’s root element with a specific object within the document. Do this by selecting a car from the Structure panel and dragging it over the main text frame on the first page. The frame will then be populated with all of the values and images that are contained within the car’s structure.

select root element

All fields are marked with square brackets and labeled with colors that match the Tags panel.

Be aware that some unwanted characters may have been inserted alongside the imported fields (e.g. tab and paragraph return characters). A useful tool for removing these characters can be found by selecting the text and choosing Edit -> Edit in Story Editor.

story editor

Reveal hidden characters by choosing Type -> Show Hidden Characters. Then proceed to delete any that are unnecessary.

Note: making text changes directly within the text frame offers the same results as edits made in the Story Editor, but using the Story Editor shows XML fields’ full names (vs. only simple brackets). This extended form can drastically simplify the editing process.

We can now customize our fields with InDesign’s graphic tools (paragraph styles, character styles, frame options etc.). In our example we’ve added labels before each field and given these labels a bold character style.

customize styles

We can also make changes to the fields found above our main image – BRAND, CAR_MODEL and TYPE. We start this process by creating paragraph styles called ‘Brand’ and ‘Model’.

Next click on the top-right menu in the Tags panel and click on ‘Map Tags to Styles’. This will display a dialog box in which we can assign one of our paragraph styles to each tag – so in our case the ‘Brand’ paragraph style to the BRAND tag and the ‘Model’ paragraph style to the CAR_MODEL and TYPE tags.

Clicking ‘OK’ should reveal the following result:

 

customize styles2

Our final customization step involves adjusting the image frame. Start by selecting the frame and reducing the width. Then right click inside the frame, select Fitting -> Frame Fitting Options and selecting ‘Auto-Fit’ and ‘Fit Content Proportionally’. Ensure that all ‘Crop Amount’ values are set to 0. All newly imported images will now be fitted to the same frame size.

image fitting options

We’ve now completed the graphical customization. The following screenshot compares the preview and standard versions of our car style:

product style - all views

Save the document as an InDesign template (.indt format) and then close and reopen it.

save as template dialog

The close and reopen step is important as we’re now opening an unnamed template instead of a named document. We can therefore reuse the template across numerous projects, which is especially useful if you’re creating huge catalogs, e.g. to have different, custom-named documents for each category.

6.1 Mapping tags to style

Assigning paragraph styles to tags can become quite complex.

banner3

7. Importing XML data (paginating)

The last section of this tutorial will see all of the cars’ elements imported to our template.

The process uses the same ‘Import XML’ method as above. As such: open the Structure panel and click on ‘Import XML’ from the menu in the panel’s top-right corner (or through File -> Import XML in the main InDesign menu). Choose our XML file and check both the ‘Show XML Import Options’ and ‘Merge Content’ options.

We now need to choose several options in the ‘XML Import Options’ dialog:

  • Create link: Ensures that any changes made to the imported XML file will be reflected in the new InDesign document.
  • Clone repeating text elements: Useful when your XML files have repeating elements, e.g. the repeating car elements in our file. InDesign will check these elements during the import process and clone them in the new document.
  • Do not import contents of whitespace-only elements: Prevents the import of elements that contain only whitespaces or break characters (e.g. paragraph returns).
  • Delete elements, frames and content that do not match imported XML: Deletes all content in the new document that is not found in the XML file.

XML option dialog - import full
Click on ‘OK’ in ‘XML Import Options’ to merge the new InDesign document with the XML elements.

result1

You may notice that the BRAND and CAR_MODEL elements have been separated:

result2

Correct this by selecting the ‘Brand’ paragraph style from the Paragraphs panel, right clicking and choosing ‘Edit Brand’. Then navigate to the ‘Keep Options’ section and add ‘1’ to the ‘Keep with Next’ field. This option will keep all ‘Brand’ styles together with the next styles.

paragraph keep options

7.1 Try a better approach

banner2-pagina-templates

8. It’s done!

Do the same for the ‘Model’ paragraph style and then you’re complete!

result3
Limitations

Users often find XML-Import to be complicated and inefficient because:

You have to convert your data to XML and this is a complex project by itself (free tutorial and samples data here: from Excel to XML);
XML templates creation and InDesign field-mapping are rigid, and you have to foresee and hard-wire many basic typographic conventions in your templates.

Overcoming the limitations of standard data publishing methods pushed us to found Pagination.com in 2009.

Pagination.com

Pagination is currently the fastest way to transform your data into beautiful documents.
It assists the creations of hundreds of catalogs and price-lists daily.
Customers of any size, industry and from all around the world, use Pagination to:

1. Integrate data from any kind of source and business application;

2. Easily create custom templates;

3. Merge data and streamline publishing tasks.

Pagination offers an end-to-end premium service available 24/7 world-wide.

View more

Free templates

EmoCore-pronto

Files: InDesign + Excel + PDF
Size: A4 – 210×297 mm / 8.27×11.69 in
Automation: Pagination.com, Tutorial
Features: Full Document Automation, Image Import, Category breaks, Automatic TOC, Multi-pricelist, Table/footer notes

Indesign-to-Excel-01

Files: InDesign + Excel + PDF
Size: A4 – 210×297 mm / 8.27×11.69 in
Automation: Pagination.com, Tutorial
Features: Full Document Automation, Image Import, Category breaks, Automatic TOC, Multi-pricelist, Table/footer notes

indesign xml template

Files: InDesign + XML
Size: A4 – 210×297 mm / 8.27×11.69 in
Automation: InDesign XML – Tutorial
Features: Partial Document Automation, Image Import, Linked Data.

View more