AdobeAdobe InDesignXML

Adobe InDesign and XML: A Reference Guide

posted by Cari Jansen February 25, 2011 51 Comments

The following notes might be helpful for those of you who are looking at doing a little more with XML in InDesign. They are by no means complete, and I’ll likely update this post in the near future, to make it more complete.

Mapping tags to 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 that will subsequently format the data marked up with a particular tag. To map XML tags to styles, select Map Tags to Stylesfrom the Tags panel menu or the Structure pane menu.

The Map Tags to Styles dialog appears. 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.

To automatically map matching Tag and Style names, click Map by Name. 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. Upon acknowledgement of the settings, imported XML content is formatted using the matched paragraph, character, table and cell styles.

When a document already contains a XML structure that is linked to content frames as well as tags to styles mapping and XML is imported, the laborious task of formatting text becomes a thing of the past.

Figure9. XML tags mapped to similarly named  paragraph styles.


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

Figure 1. 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: file:///Servername/RestOfPath
Where ServerName reflects the name of the Server you’re connected to.

Figure 2. Image path samples.


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 3. Table attributes.

XML Example

Table heading here
Fruit flies

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.

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. In the example above that would be the Tableelement.


Figure 4. InDesign Namespace reference for version 4 and 5.

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 5. Paragraph and character style attributes

XML example
<strong>van Gogh Art Exhibition</strong>
Vincent Willem van Gogh
(30 March 1853 – 29 July 1890) was a Dutch ... most popular and most expensive pieces.
Van Gogh spent his early dult life ... until he encountered Impressionism and Neo-Impressionism in Paris.

You may also like


Sly October 28, 2015 at 8:53 pm

Hello Cari,
I’m creating a catalog. I have manage how to flow an XML, styling, and so on, thank to your tutorials.ButiIn this catalog, I have to create two patterns : 1) 4 articles with details/page 2) many articles with less details (same collection)/page. I don’t manage to tell to ID that there two different structures in my XML. How can I manage to create two different repeating patterns ?

neeta February 7, 2015 at 2:50 pm

I have a xml where same tag is used for head 1, head 2. I can’t change the tag, is there any way to add attribute and map that attribute with indesign style.

Cari Jansen February 24, 2014 at 7:10 am

@locavore afaik there are no public updates for this. Adobe has however released more documentation on IDML. See:

locavore February 9, 2014 at 12:48 am

Where can we find out if there are any changes to XML namespace in more recent versions of InDesign (CC)? There is no online reference that I can find that says specifically if it is the same. I’d like to verify that the aid: should be changed or not for tables in InDesign CC

Cari Jansen February 7, 2014 at 10:15 am


You can use a workaround:
if you need to access styleNameA in a style group, transform the <p aid:pstyle=”styleNameA”> to <styleNameA>, this way all you need to do is add a new style-mapping from </styleNameA><styleNameA> to “styleNameA (StyleGroupName)” .</styleNameA></p>

studiovanpelt July 11, 2014 at 12:27 am

Hi Cari, i didn’t understand that:
For example in
I want to get the “EK” paragraph style in a style group called “text”

And in:

Table header 1
I want to get the “h2″ in a style group called “headers”.
How do you do that?


Cari Jansen July 11, 2014 at 12:53 am

@studiovanpelt What is it you are trying to achieve? if you have a pstyle assigned as part of your xml import, it doesn’t map to a style inside a style group. If you are referring to a style group as part of xml-import you’ll likely need to use an xslt to get the import working, or xml-import script of sorts. Cari

Pere January 27, 2014 at 10:31 am

id:pstyle with style in style group?

Manikandan December 7, 2013 at 5:55 am

agatebook xmlns:aid=””

Manikandan December 7, 2013 at 5:53 am


When i imported xml file into indesign version 6 “” as per your guidance aid:pstyle=”para” file not mapped as per style please advice.

Cari Jansen December 27, 2013 at 12:38 pm

did you add the ns info to the start of the XML file? Is the paragraph style ‘para’ added in the paragraph styles panel? if it is in a style group remove it from the style group and add it at top level.

William October 30, 2013 at 8:46 am

Hi Cari, Where shall a person find beginning instruction to use XML with InDesign? Thank you.

Shaji May 21, 2013 at 8:25 pm

Thanks for the valuable information about “aid” concept.
How do we handle “Style Group” paragraph style.
Using “aid:pstyle” it won’t work for Style Grouped paragraph style.
Is there is any attribute which can handle the style grouped style.


Cari Jansen May 10, 2013 at 12:23 am

@Johnny you’re most welcome. Glad it was helpful :) Cari

johnnycho May 8, 2013 at 1:35 am

No, it was actually my typo, not yours, that was the issue. By the way, this is one of the most helpful and informative blog posts EVER. Thank you SO MUCH!

Cari Jansen April 23, 2013 at 10:03 am

Not a problem Johnny. I’ve just reviewed the XML Notes in my blog post and fixed the ‘smart-quotes’ which I think might be the typo you were referring to? When I have some spare time I’ll add some additional notes to this blog-posts. Have added it to my list as a post that needs updating :) Cari

johnnycho April 23, 2013 at 5:47 am

Please disregard my last message. I figured it out. A typo in the namespace declaration that you illustrated in Figure 4.

johnnycho April 23, 2013 at 2:59 am

Thank you for this very helpful tutorial. I’m importing a table into my InDesign 5.5 file using XML. The table data shows up fine, but it’s not formatted, even though I have a basic table style and I’ve linked it to the table tag name. What’s strange is that when I select the data, the table styles are all greyed out, meaning it won’t let me apply a table style to the data. Have you ever run into this or do you know why it might be doing this? Thanks so much.

SME February 18, 2013 at 7:21 pm

Anwer, I mean update.:). BTW, Does Image is always referred using href or it can come without href tag? We are trying read indt XML programitically and wanted to have some reference base which will be always there to indicate image in XML.

Cari Jansen February 14, 2013 at 11:06 am

@SME I was afraid that would be the answer :( :(

SME February 6, 2013 at 7:20 pm

Thanks for answer. It doesn’t work. We tried but no success. :(

Cari Jansen February 6, 2013 at 8:49 am

@SME Hmmm… interesting question. I’ve never tried that, and my gut feel says ‘no’, as I’m not sure how InDesign could pull in the graphic and retain a link to it. As far as I’m aware, InDesign doesn’t support placing web graphics. But if you do get that working let us know for sure :)

SME February 4, 2013 at 2:59 pm

Can I use internet location for image tag? If Yes, how it would look like in XML?

Cari Jansen February 2, 2013 at 9:22 am

@locavore interesting… must test that… I generally ensure when data is extracted from a database into XML-for-InDesign format, the row count is set.

locavore December 21, 2012 at 11:26 am

Seems to me I had success leaving the aid:trows value empty (the rows would be calculated from the cells) — and if I set it to an arbitrary number, the table would truncate when it got to the value that matched cells count divided by that number. This was for a table that ran for many pages with repeating heads, developed quite some time ago and probably needs to be retested to verify aid:trows=”” is OK to use.

Cari Jansen October 22, 2012 at 7:06 am


To give you a real life example: I developed an XML repetitive run-in template that generated a list of public schools some time ago and and each had their school crest included as part of the XML import. The crest needed to be fully visible and centered in a placeholder graphic frame.

However, I’ve also recently worked on an XML run-in template, that is not repetitive, and indeed used a JavaScript that automatically applies at the end of the XML import and sizes certain images to a specific width/height.

I guess in a way it depends on the kind of document template you are working on as to which works best.


dma October 18, 2012 at 11:57 am


You mentioned, “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.”

Can you provide an example of an image element that would allow for position and scaling within inDesign on import? I currently assign an attribute to handle inline and breaking images but use that to apply a style via JavaScript. I have been unable to style, scale, or position an image them on import alone.



Cari Jansen October 4, 2012 at 9:55 pm

Hi Paul,

You can use something like Oxygen XML Editor. Another one would be Stylus Studio (Windows only). As far as I’m aware both allow to build XSLT, apply to XML and see/test result.


Paul Harvey October 3, 2012 at 7:44 am

Hi Cari,

Thanks for the suggestions. I’ll look into the XSLT row count – sounds like something to get my teeth into! In the meantime, I’ve changed the XSLT to create a table with two rows for each record and it works a treat.

I’ve been attempting to remove empty elements using XSLT, but can’t seem to get it to work. I can’t work out whether it’s down to part of the XSLT (I’ve tried several examples from the net) or the way Indesign interprets it. Do you know of any software that will allow me to work on the Indesign XSLT ‘live’ (similar to the way Dreamweaver will allow you to work on live code)?

Cari Jansen September 27, 2012 at 8:58 pm


Where I’ve worked with table data, we’ve calculated the amount of ‘rows’ (records) exported, so that the row number can be defined properly. You could possibly do this with XSLT as well (you’d need to check with an XSLT expert). The same applies for the empty elements, you can remove these during import (XSLT) or prior to import using something like a ‘GREP’ Find/Replace even.


Paul Harvey September 26, 2012 at 1:56 pm

Hi Cari,

Thank you for this information, I’ve learned a lot about Indesign, XML, and XSLT in the last couple of weeks. I’m using some of these tips in a document I’m creating (Club Diary). Exported XML from Access, importing and applying an XSLT with aid: tags present to define character styles in a table.

I do have a couple of questions:

1. Do you have to specify a number of rows (in aid:trows=”xx”)? As the data coming from the database could contain any number of records (and therefore rows) it would be preferable to not have to specify a number in this attribute.

2. When importing XML and a blank field is encountered, is it possible to not display the field placeholder and remove the blank space between lines?



Cari Jansen August 3, 2012 at 10:11 am

@Dan I’m not sure how InDesign manages attributes, as far as I’m aware they import ok, but on the layout side out-of-the box there’s nothing really that would happen as far as I know. But as @locavore mentions you can basically do anything with the XML on import or even after import to make it behave differently to what InDesign can do out of the box. Either by running an XSLT, which could turn attributes into elements that InDesign can read/format or even by developing some JavaScripts that interact with the XML and apply certain additional formatting controls, placements etc. (I generally outsource the Javascripting side of things, build the templates, review the XML and then consult — Cari

dsoileau August 2, 2012 at 8:52 pm

Hi Cari,
Yes, my question is about adding multiple unique attributes to a tagged element (span) via the Structure pane. Experimentation revealed that a space between values works, though I’m not sure about why that works. Any insight into how the attributes are managed by InDesign would be appreciated.

locavore August 1, 2012 at 12:32 am

@Dan: did you try entering “class” as the attribute name and then two words separated by a space for the attribute values. i.e. “italic text-indent” (without the quotes)? This works for me in IDD CS5.5 using the Attributes dialog.
If you are using a DTD then both the attribute name and the attribute values must be valid. It looks like you are imitating HTML syntax, in which case the class attribute and free-text values for it are OK. For example:
<p class=”h1 title article”>A title</p>
<p class=”body no-indent”>A paragraph with an inline <emphasis class=”italic”>emphasis</emphasis> and <keyword class=”bold italic keyword”>keyword</keyword>.</p>

You could remap this with XSLT during export to achieve HTML like this:
<h1 class=”title article”>A title</h1>
<p class=”body no-indent”>A paragraph with an inline <em class="italic">emphasis</em> and <b class="bold italic keyword">keyword</b>.</p>

It is pretty easy to map from a paragraph or inline XML element to similar HTML elements. If you need to make complex groups of content into nested divs, you will probably need more complex XSLT for your grouping. Note that if you want to build a complete HTML file from InDesign content, you have to define the html, title, and body elements in the XSLT and then you need to determine how to handle each separate text flow that you have tagged in the InDesign file, whether it should be in its own div in HTML or not.

dsoileau June 27, 2012 at 9:28 pm

Hi Cari,
In my InDesign document I have a span element that requires an attribute named class with two values: “italic” and “text-indent”. But InDesign won’t allow me to have two attributes identically named, and both require the same name (class). Is it possible to enter multiple values in the Edit Attribute dialog box value field for a single class attribute? If so, what is the separator?

Cari Jansen July 20, 2012 at 8:05 pm

Hi Dan,

I’m not sure what tag in the structure panel you are trying to add an attribute to, but you can add multiple attributes to a tag when setting up structure for XML in InDesign. What you can’t do is add two attributes with the same name. Are you applying the attributes via the Structure pane?


mawa_73527 March 15, 2012 at 5:03 pm


I am looking for a way to format column width other than using points. I am looking for a way to have the columns withs in tables to be relative like in SGML 1* or 2* or even 1.7* and I would want to mix this with fixed widths e.g.:
first col be always 100 points; second col be relative 1; third col be relative 2; and last be 80 points.

Can indesign compute this if the width of the table is known?


Cari Jansen March 17, 2012 at 1:08 pm

Hi Matthias,

You’d need to run an XSLT on import that calculates this for you. E.g. if you know in advance what the overall width of the table would be, and you’ve got ‘proportional’ settings e.g. Column 1 20%, Column 2 40% etc. you can get your XSLT to convert this to points during InDesign XML import.

Alternatively, you could run a script that processes columns proportionately to the width of the parent text frame they appear in.

— Cari

Cari Jansen March 8, 2012 at 3:31 pm

Pleasure @SSHunho I think you’ll most likely need to customise with scripting for object style level support. – CJ

sshunho March 7, 2012 at 12:52 am

Hi Cari,

Many thanks for the articles. I’ve learned a lot about InDesign XML attributes and InDesign Namespaces. This is really useful.

Just a quick question. Does InDesign XML support Object Styles as it is with Paragraph and Character style attributes? Is there anyway I could include object style in the XML?

Thanks again!

Kurtis February 22, 2012 at 1:19 am

Very useful! Thank-you.

Jamie August 5, 2011 at 3:29 am

The tag got removed from the comment. I wanted to say that the tag does not have to be named “Image” for InDesign to expect linked images.

Jamie August 5, 2011 at 3:08 am

Worth pointing out that images don’t have to be linked using a tag named “”. InDesign will assume the href attribute of any tag is for an image.

Sunny July 6, 2011 at 1:48 pm

I have an XML file with table and I have converted this table to CALS table and added indesign style through XSLT. Unfortunately, the styles are not applied when the XML is improrted to Indesign. Can any one suggest a solution pleae?

Claudino March 11, 2011 at 1:54 am

Hi Cari,
Thanks lot for this article!

I have a related problem that made me google for hours and still not found any answer.

I have Indesign tagged tables that I’d like to export to xml, but I need them without the “aid:” elements. When I untag all the text in a table, it exports fine, but when I tag any paragraph or other element inside that table, the “aid:” arise, and the final xml should’t have them. Is this possible?

Thanks in advance

Cari Jansen February 25, 2011 at 9:38 pm

@Loic :) great idea :)

loic February 25, 2011 at 9:24 pm

Hi Cari,

Thx for your answer. It’s really encouraging :)
A script ? You should keep in touch with marc who should really enjoy such a project 😉

A+ Loic

Cari Jansen February 25, 2011 at 7:07 pm


Yes XML means you don’t need to work with everything inline to get EPUB content in the correct order.

It is by no means perfect, but it does mean that hypothetically speaking you wouldn’t need to redesign your publications for EPUB output if they already exist in for print-layout purposes.

But I must be honest and say that practically speaking it is often quicker to build an inline document.

A way around that would be for someone to develop a script that could assist in building the XML structure. A script for instance that recognises groups and inserts those as ‘nested’ tags :-)

The script I think would also need to review the default ‘tagging’ order when we use ‘AutoTag”. :-)

loic February 25, 2011 at 6:49 pm


Yes, I heard about XML/epub relationship but never really played with it. Waiting for your next post so it can answer one of my questions ie does using xml tagging avoid setting an unique flow (anchored objects etc…) or is it just for ordering contents ?

Cari Jansen February 25, 2011 at 6:32 pm

@Loic, Merci beaucoup pour les mots gentils!

XML can also be used for EPUB creation. a) you can control which content is going to be included in the EPUB through the Structure inclusion and b) you can control the order in which it will appear in the EPUB.

I hope to do a write-up about that at some point, have so many other things to do at the moment :) Just need more hours in the day :-)

loic February 25, 2011 at 5:56 pm

Yes, this one rocks !!! Set styles on XML structure is very promising :)


Leave a Comment