Fan of creative technology, elearning, instructional design and a little geeky

Adobe InDesign and XML: A Reference Guide

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:

  1. 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.

  1. 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.
  2. 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.

<Root xmlns:aid="" 

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


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

Figure 3. 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 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>

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 &#x0009;
 1/4 &#x00BC;
 1/2 &#x00BD;
 3/4 &#x00BE;

Figure 8. Special characters.

Similar posts
  • How to change the colour of bullet points in InDesig... A few weeks ago I recorded a short quick tip tutorial. InDesign’s Control panel, gives users a quick and easy way to format text as a bulleted list. Highlight the text, and click the Bulleted List button in the Paragraph Formatting Controls mode for the Control panel. This applies a universal bullet character as the [...]
  • Creating a pop-up window in a PDF with Adobe InDesig... In the following YouTube tutorial, we’ll create an interactive PDF from Adobe InDesign, in which we click on a button, which in turn opens up a simple pop-up window containing a close-box. When the close-box is clicked the pop-up window disappears [...]
  • InDesign: Facing pages with odd-numbered left pages Back in 2004 I wrote a tip for InDesign CS on how you could have the first page of your document be a left page AND have it start with page number 1. It’s hard to believe this is almost a decade ago… But a recent question on Facebook, made me think I should really [...]
  • Negative Lookbehind – GREP for Designers This is the fourth and final blog-posts in a series of posts on lookaheads and lookbehinds in GREP, written after speaking at the Perth InDesign User Group. My speaker notes are also available: What is GREP? (PDF download) (2.4Mb). In the previous three posts I briefly introduced GREP, and we took a look at Positive [...]
  • Positive Lookbehind – GREP for Designers This is the third in a series of blog-posts about GREP, written after speaking at the Perth InDesign User Group. My speaker notes are also available: What is GREP? (2.4Mb PDF download). In the previous two posts I briefly introduced GREP, and we took a look at Positive Lookahead and Negative Lookahead. In this post [...]


  1. Sunil Yadav Sunil Yadav
    June 5, 2019    

    Is there any xml structure for creating and applying group paragraph style?

  2. Neil Neil
    September 25, 2018    

    Hi Cari,
    I’m working on producing a suite of InDesign documents, which will be populated using XML data, taken from our website.
    Some of the fields have inline styles, which appears as part of the text, when imported in to InDesign. (see below for example)

    <![CDATA[ Students often elect to undertake field trips either individually or as a group as part of their broad range of study. Bristol Zoo and a local zoo farm are favorite locations for the study of animals for Action Analysis studies.You’ll be given the opportunity to work with the British Film Institute (BFI) Animation Boot Camp, which provides workshop instruction for young people from around the UK. ]]>

    Is there any way to get InDesign to recognise this styling and either implement it or remove it?


  3. March 20, 2017    

    Hello Cari,

    I have to show two tables side by side , so i was thinking to create a parent table of single row with two cell. and in those two cell want to put two other tables.

    however i am not able to nest tables. ie. when i am importing this xml , it is failing.

    is there any solution for this problem

    • May 25, 2017    

      What you could try and do is have an external paragraph style for your tables, that has span columns set to split 2, but it will be a bit of a hit and mis to get them to position perfectly side by side…

  4. Sly Sly
    October 28, 2015    

    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 ?

    • January 1, 2016    

      You’d need to run a script on import I believe, and insert an attribute for each collection of content that flags which of the run in pattern needs to be used. The script will then ensure that the right master pages are used for the XML run in.

  5. February 7, 2015    

    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.

    • January 1, 2016    

      You’ll need to use an XSLT on import to change the tag based on the position in the text it appears in.

  6. February 24, 2014    

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

  7. locavore locavore
    February 9, 2014    

    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

  8. February 7, 2014    


    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 studiovanpelt
      July 11, 2014    

      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?


      • July 11, 2014    

        @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

  9. Pere Pere
    January 27, 2014    

    id:pstyle with style in style group?

  10. Manikandan Manikandan
    December 7, 2013    

    agatebook xmlns:aid=””

  11. Manikandan Manikandan
    December 7, 2013    


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

    • December 27, 2013    

      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.

  12. October 30, 2013    

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

  13. Shaji Shaji
    May 21, 2013    

    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.


  14. May 10, 2013    

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

  15. johnnycho johnnycho
    May 8, 2013    

    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!

  16. April 23, 2013    

    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

  17. johnnycho johnnycho
    April 23, 2013    

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

  18. johnnycho johnnycho
    April 23, 2013    

    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.

  19. SME SME
    February 18, 2013    

    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.

  20. February 14, 2013    

    @SME I was afraid that would be the answer 🙁 🙁

  21. SME SME
    February 6, 2013    

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

  22. February 6, 2013    

    @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 🙂

  23. SME SME
    February 4, 2013    

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

  24. February 2, 2013    

    @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.

  25. locavore locavore
    December 21, 2012    

    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.

  26. October 22, 2012    


    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.


  27. dma dma
    October 18, 2012    


    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.



  28. October 4, 2012    

    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.


  29. October 3, 2012    

    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)?

  30. September 27, 2012    


    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.


  31. September 26, 2012    

    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?



  32. August 3, 2012    

    @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

  33. dsoileau dsoileau
    August 2, 2012    

    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.

  34. locavore locavore
    August 1, 2012    

    @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.

  35. dsoileau dsoileau
    June 27, 2012    

    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?

    • July 20, 2012    

      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?


  36. March 15, 2012    


    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?


    • March 17, 2012    

      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

  37. March 8, 2012    

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

  38. sshunho sshunho
    March 7, 2012    

    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!

  39. Kurtis Kurtis
    February 22, 2012    

    Very useful! Thank-you.

  40. Jamie Jamie
    August 5, 2011    

    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.

  41. Jamie Jamie
    August 5, 2011    

    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.

  42. Sunny Sunny
    July 6, 2011    

    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?

  43. Claudino Claudino
    March 11, 2011    

    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

  44. February 25, 2011    

    @Loic 🙂 great idea 🙂

  45. February 25, 2011    

    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

  46. February 25, 2011    


    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”. 🙂

  47. February 25, 2011    


    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 ?

  48. February 25, 2011    

    @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 🙂

  49. February 25, 2011    

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

Leave a Reply

Your email address will not be published. Required fields are marked *