The following is a reference guide I have compiled over time for those of you who are looking at doing a little more with XML in InDesign (originally published Feb. 2011, last updated Feb 2018). If you have any extra information you’d like to see added to this guide, feel free to message me.
Mapping XML tags to InDesign styles
Mapping XML tags to styles, creates a link between content marked up with an XML tag and a paragraph, character style, table or cell style and will subsequently format the run-in XML data in the InDesign document based on the mapping references .
To map XML tags to various InDesign styles:
- Select Map Tags to Styles from the Tags panel menu or the Structure pane menu.
All Tags available in the Tags panel are listed. The Style menu provides a drop-down menu next to each Tag that contains a list of all Paragraph, Character, Table and Cell Styles to which Tags may be mapped.
- Click Map by Name in the Map Tags to Styles dialog box to automatically map matching Tag and Style names. All matching names are automatically linked up. For any Tags not mapped, you can choose an alternative mapping option from the drop down-menu.
- After you’ve linked all used tags to document styles, click OK.
Imported XML data is formatted now automatically formatted using the matched paragraph, character, table and cell styles.
InDesign Namespace
When defining attributes that refer to a specific eXtensible Markup Language Namespace (XMLNS), the namespace must be declared as part of the XML. Where InDesign 4.0 and 5.0 namespaces are used, both namespaces may be entered in the Root element of the XML file or else inside the element referring to them.
Namespace |
---|
<Root xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/"> |
Figure 1. InDesign Namespace reference for version 4 and 5.
Images
An image reference in XML must provide a full path-name to the image location as a href attribute (this is similar to how the img tag works in HTML). When you apply an Object Style to the graphic frame that sets the frame options, you can control the positioning and scaling of the image as it is being placed in a tagged graphic frame during XML import.
Image element sample |
---|
<Image href="File:///Volumes/DOCS_IMAGES/2008_Sydney/IMG_1806.JPG"></Image> |
Figure 2. Example of Image element with reference to image location
Image reference examples | |
---|---|
Images stored in same folder as xml file | href="File:///image.jpg" |
images stored in a sub folder inside the same folder as xml file | href="File:///foldername/image.jpg" |
Images stored anywhere and referenced by accessing the full path name. This is referred to as an absolute path name | In the Documents folder on your PC: href="File:///C:/Users/username/Documents/ |
In the Documents folder on your Mac: href="File:///Users/username/Douments/ |
|
Where username is to be replaced with your username (in my case that would be “carijansen”) and RestOfPath points to sub and sub-sub-folders inside the Documents folder | |
Images stored on another volume (server) | from a Macintosh OS: File:///Volumes/VolumeName/RestOfPath |
Where VolumeName reflects the volume. from Windows: F ile:///Servername/RestOfPath Where ServerName reflects the name of the Server you’re connected to. |
Figure 3. Image path samples.
Tables
Tables in InDesign CS3 and higher can be formatted using Table and Cell Styles.
These styles may be applied as part of the XML import by including appropriate style attributes to the XML table. The following attributes can be applied:
aid:table |
defines that the element is a table |
aid:trows |
total number of rows the table contains |
aid:tcols |
total number of columns the table contains |
aid5:tablestyle |
(ID5 specific), Table Style that formats the table |
aid:theader |
defines cells as being part of a header row |
aid:tfooter |
defines cells as being part of a footer row |
aid5:cellstyle |
(ID5 specific), Cell Style that formats table cells |
aid:crows |
number of rows across which the cell spans< |
aid:ccols |
number of columns across which the cell spans |
aid:ccolwidth |
column width of cell, measured in points |
Figure 4. Table attributes.
XML Example |
---|
<Table aid:table="table" aid:trows="2" aid:tcols="4" aid5:table style="TableWithHeader"> <Cell aid:table="cell" aid:theader="" aid:crows="1" aid:ccols="4" aid:ccolwidth="134">Table heading here</Cell> <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="134">Fruit flies</Cell> <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="134">23</Cell> <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="134">34</Cell> <Cell aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="134">234.9</Cell> </Table> |
Figure 5. Table XML sample.
Note that a table cannot be placed into InDesign without its parent Story element. The aid and aid5 prefixes used as part of the attribute names that define specific cell formatting are indicative of these names being part of the InDesign 4.0 and 5.0 XML namespaces.
Paragraph and character styles
Formatting with paragraph or character styles can also occur during XML import and works similar to using the table attributes. Use the following attributes for paragraph or character level formatting:
Attribute | Description |
---|---|
aid:pstyle |
Paragraph Style formatting |
aid:cstyle |
Character Style formatting |
Figure 6. Paragraph and character style attributes.
XML example |
---|
<title aid:pstyle="head_large">van Gogh Art Exhibition</title> <intro>Vincent Willem van Gogh <dob aid:cstyle="smallcaps"> (30 March 1853 – 29 July 1890)</dob> was a Dutch ... most popular and most expensive pieces.</intro> <body>Van Gogh spent his early dult life ... until he encountered Impressionism and Neo-Impressionism in Paris.</body> |
Figure 7. Paragraph and character style XML sample.
Special characters
List of special characters (I’ll add to this over time, feel free to message me if you have additions):
Character | Description |
---|---|
en-dash |
& #8211; |
em-dash |
& #8212; |
en-space |
& #x2002; |
em-space |
& #x2003; |
tab | 	 |
1/4 | ¼ |
1/2 | ½ |
3/4 |
& #x00BE; |
Figure 8. Special characters.
Leave a Reply