XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.


The process of formatting and typesetting documents has come a long way in the relatively short span of time that modern computers have been around; the process has typically revolved around formatting scientific or technical documents using a variety of command-line tools. However, the latest version of Adobe's page-layout application, InDesign, integrates XML files into its visually oriented publishing workflow.

Old-School Document Generation

One of UNIX's first killer applications was document typesetting. While making documents is no longer the sole reason to invest money in a box that flips bits as fast as possible, the purpose behind it remains just as relevant today as it did 30 years ago when troff first hit the scene: to offload as much work as possible to the machine, thereby allowing the author(s) to concentrate on the content of the document, rather than its appearance.

troff typesetting is achieved by feeding a specially formatted document to a series of preprocessors, repeatedly piping the output of one preprocessor to the input of the next. This preprocessing will continue until the content of the original document has been suitably massaged and can parsed by the troff utility, which in turn produces a PostScript copy of the document.

New-School Document Generation In a Nutshell

A New Tool Is Born

Fast-forward 20 years from the birth of UNIX, when HTML is being sent across the Internet at an exploding rate. Realizing that they might be on to something, the W3C simplifies and standardizes HTML's ancestor, SGML, to become XML. Serving as a general-purpose data-exchange format, XML syntaxes are created for countless applications, including vector graphics (SVG), remote procedure (XML-RPC) invocation, and document formatting (XSL-FO).

While there are many simple XML applications, XSL-FO definitely doesn't fit this classification. This is simply due to the complex nature of controlling the layout for a multiple-page document; headers and footers, margins, all sorts of font properties (its family, size, weight, leading, kerning, alignment, and countless other details) must be taken into account to transform a marked-up document into one that can be professionally printed and bound.

To avoid interacting with this level of complexity, authors typically mark up their content with another syntax (such as DocBook), which is then transformed with XSLT into another syntax for presentation -- creating a pipeline of XML tags that are passed between processors, (similar to troff's pipeline). And while XSL-FO is well-suited for documents such as theses, manuals, and other technical references -- documents that typically have a simple layout with a restricted set of fonts, colors, and external resources -- it is virtually impossible to format anything that doesn't fit within a rectangular box.

However, this "box" limitation isn't an oversight; the W3C never intended the XSL-FO specification to fill any other shoes. After all, anyone who is in need of a customized XML workflow to suit their needs is free to create it, which is exactly what Adobe has done with the latest release of its Creative Suite software.

In Steps InDesign

InDesign, a component of Adobe's Creative Suite, is a page-layout program aimed at Adobe's core audience: professional graphic and media designers. Whereas XML and troff pipelines are primarily used to create technical documents, InDesign is primarily used to create visual documents such as brochures, advertisements, and other media (there are exceptions, of course).

In this brief tutorial, we'll walk through a simple example of how InDesign CS allows a publishing workflow to be broken into two pieces: developing the document's appearance and then its content.


Applications that interact with documents (whether it be InDesign, an XSL-FO processor, web browser, or even Microsoft Word) use the concept of styles, which allow any number of components of a document to have their appearance governed by a style declaration. Typically a style declaration controls an object's appearance: color, spacing, and other properties that are dependent on the application's domain.

XSL-FO styles are created using XML attributes, many of which are analogous to CSS-style declarations (such as font-family and border-left-width). InDesign allows authors to define styles in a manner that is familiar to anyone who has worked with similar design programs; the following image shows how basic character properties of the "employeeInfo" style are defined:

A screenshot illustrating how paragraph styles are defined through InDesign's interface.
Figure 1: A screenshot illustrating how paragraph styles are defined through InDesign's interface.

Adding XML to the Mix

Among other new features included in this version of the application, InDesign CS introduces an XML compatibility layer that allows it to import and export XML files that encapsulate the information contained within the document.

In the previous version of InDesign, the written material of our documents was tied up in the text blocks that were defined in the document itself (indeed, this is the case for most files that are manipulated with a proprietary application); similarly, the only way to manipulate other resources used within the document, such as images, was through the application's interface. This is no longer the case with InDesign CS.

InDesign's XML Savvy

In much the same way that CSS provides a way to abstract the appearance of an XHTML document, InDesign CS' XML-compatible layer provides a powerful way to separate the content and style of print documents that, in the past, have typically had their content and presentation tied up in a knot.

Essentially, this layer allows you to define the template of your document from within InDesign, and to develop the content of the document in any text editor. Once the template and content have been finalized, it is simply a matter of merging the two together, and exporting the final work to the format of your choice.

A Simple Scenario

To see how InDesign's XML layer can ease a publishing workflow, let's walk through a simple scenario where a small company needs business cards printed for each of its employees. While the cards will share some information (such as the company's name), each card will have unique information for the rest of the fields (such as the employee's name, email address, etc.).

Traditionally, this process would be completed in one of two ways, each with its own benefits and drawbacks:

  1. By creating one InDesign file for each employee and copying and pasting the common information between the documents while keeping the employee's unique information separate, or...
  2. By creating one InDesign file for the entire company, and merely changing the unique information for each employee by cutting and pasting before we export the document to a printable format.

However, the two methods outlined above also share the same problem: if, at any point after exporting the file, we make a change to the template, then the change must be reflected in every file that uses the template. InDesign alleviates this problem by allowing us to define a template and an XML file to provide the necessary information for a document. Thus, the XML file acts as a kind of simple data store, allowing the data to be created, manipulated, or used with other applications.

A Simple How-To

The first step in our workflow is to define the template we'll be using for our business cards. In order to do this, we'll have to:

  1. Set up the layout of the business card, thereby creating the static content that will be shared among all of the cards.
  2. Specify the text blocks (and optionally any images) that will vary from one card to the next (in our example this will consist of the employee's name, address, email, and web site).
  3. Define the styles that will be applied to control their appearance.

This process can be seen in Figure 2; the employee's email address, email, and phone number have been designated as variables using the InDesign Tags palette, and are mapped to the "employeeInfo" style (defined in Figure 1), while the "employeeName" variable is mapped to a style of the same name.

Defining how the elements of our XML file will appear using the styles declared in our InDesign document.
Figure 2: Defining how the elements of our XML file will appear using the styles declared in our InDesign document.

As you can also see in the figure above, the four variables for each of our business cards are represented as sibling elements under a common parent element named Root. Following the rule of least surprise, the XML document that we will import must follow the same structure. The following code is a listing of the XML documents that represent two of our company's employees:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- contents of dave.xml -->
  <employeeAddress>1234 main street calgary, ab, ca a1b 2c3</employeeAddress>
  <employeePhone>(403) 555-5555</employeePhone>
</Root> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Root> <!-- contents of dylan.xml --> <employeeName>dylan mckay</employeeName> <employeeEmail>joey@fivevoltlogic.com</employeeEmail> <employeeAddress>1234 main street calgary, ab, ca a1b 2c3</employeeAddress> <employeePhone>(403) 555-4444</employeePhone> </Root>

Importing our XML file is simply a matter of bringing up a contextual menu and locating the appropriate file on disk.

Importing an XML file to populate the placeholders with an employee's information
Figure 3: Importing an XML file to populate the placeholders with an employee's information.

After importing each XML file, the placeholders of our InDesign template will be populated with the corresponding data from the imported file. Thus, exporting a print-ready business card for all of the company's employees is only a few mouse clicks away.

The final series of business cards.
Figure 4: The final series of business cards.

Closing Tag

Adobe has applied the template concepts used in other XML technologies to InDesign's visual environment (and made them accessible to designers in the process), allowing InDesign to cooperate with applications on a level that was previously impossible.

And while this tutorial provided a very brief glimpse into InDesign's XML capabilities, it is by no means a comprehensive resource; interested readers can find more information from Adobe.

1 to 12 of 12
  1. Export tables to XML
    2009-12-31 15:29:31 
    I'm desiring to export to XML from Indesign as eh dreamweaver export cause more trouble that it seems to be worth. {No CSS used in the direct ASP] My workflow requires print & web publication (to ASP pages.)
    Everything seems to be OK - except tables. Lots of extra code.

    What is the best way to export to XML for this purpose (straight HTML tables)

    THX - new to this use of XML.

  2. XML Tutorials
    2009-09-21 19:39:48 
    Does Anyone know of some links to find Video Tutorials for XML with Adobe products?
    Looking for beginer type stuff to watch and learn.


  3. Learning XML on the fly
    2009-07-30 13:53:27 
    Hi everyone, I'm fairly new to xml with regard to indesign and I've been reading a number of sources trying to wrap my head around it. I had a few questions and despite a rigorous search, I couldn't find the answers I desperately seeked. Anyway I hope someone could provide some insight.

    My studio is producing a direct mail promotional piece, and it needs to be personalized by with a database of names (let's say a minimum of 1000). I've figured out how to create a master and tag elements so that when the xml file is imported the tags are populated with the proper information.

    Here's my dilemma, from my understanding indesign does not create new pages based on the template for each recurring group of elements. So what I did was, create a multipage document using my template and threaded the text frames accordingly so that the information flows from one piece to the next.

    Now for a short run this would be fine, but this project demands a minimum run of 1000 unique pieces. Based on what I have done so far, that'll cause havoc creating a document that large. My creative director however, insists that there's a way to automate the printing of each unique piece (we're doing this in-house) from a single template without creating new pages and threading all the elements. I've done a lot of research and I have yet to find any evidence of such a workflow existing.

    Can anyone provide some clarification on this issue and what my best course of action would be to accomplish this project goals please? Thanks everyone!

    • Learning XML on the fly
      2009-08-31 13:12:28 
      try using the data merge function instead... you'll find it very straight forward and its well documented in the InDesign help files.
  4. Using XML Node To Populate Multiple Text Areas
    2008-12-11 13:59:06 
    I found your article very helpful and I was able sucessfuclly export my database tables into an XML file that InDesign would accept. I linked the nodes to text fields and I was in business...almost.

    It seems that I can only link an xml node to one text field? I have a case where I need to reuse a nodes values multiple times and if I assign it to another text field, I lose it on the first one....

    Is there any way around this very strange limitation? Am I not understanding something correctly?

    Any help would be appreciated.
    I am using CS2 but might be able to upgrade if that would help.


  5. CMS Tool to Export XML for InDesign
    2008-10-24 11:02:36 
    Does anyone know if there is a web-based CMS system that has XML output capabilities?  I would like to find out if there is something available that could generate HTML web pages and also XML based content for import into inDesign.
    • CMS Tool to Export XML for InDesign
      2008-12-12 17:37:43 
      Yes, SDL Tridion is a fully XML driven CMS. You can pump content out in any format, including XML. It even has an Indesign Connector, so you can drag&drop managed content directly into your Indesign .indd.  Plus its targetted at multi-site & multi-lingual customers, so if you have a brochure or something in lots of languages, it will automatically churn your brochure out in all those languages.  
  6. Importing XML
    2007-06-13 01:05:37 
    Hi i am new here.
    How to setup XML file that are going to be import into Indesign without going through complex code ?

    Client often want us to used xml document generated from Microsoft .docx directly into Indesign. Importing XML was easy but setup an automated workflow using XML is hard. How can we setup a xml document that are really to import into Indesign without using Indesign and going through those complex code?

    • Importing XML
      2009-01-21 10:46:08 
    • Importing XML
      2008-03-12 09:12:25 
      Hi sir,
      I am new in indesign xml i have to automate the indesign which scripts can i use do you have sample scripts plese send my address

      Thanking you

  7. What about XSL export?
    2005-11-26 07:40:16 
    It's nice that InDesign can now export data as XML. But what about the other part of the content/design separation: the design? Can InDesign export XSL-FO? In fact, I find exporting the design much more useful than the XML part. An example application could be to use the design as a template to create PDF docs on a server.

    Does anyone know how to do this?

    • What about XSL export?
      2006-08-10 10:55:56 
      Please see at URL http://www.renderx.com/tools/inx2fo.html.
      Probably it is the thing you need.
    • What about XSL export?
      2006-06-29 08:05:50 
      • What about XSL export?
        2006-08-10 10:57:47 
        Please see at URL http://www.renderx.com/tools/inx2fo.html (http://www.renderx.com/tools/inx2fo.html) .
        Probably it is the thing you need.
      • What about XSL export?
        2006-08-10 10:54:23 
        Please, see at http://www.renderx.com/tools/inx2fo.html - probably it is the thing you need.
  8. Will RSS work as well.
    2005-02-18 11:14:25 
    I am new to XML and RSS and have a problem. Our company has me laying out an online website, an email newsletter and a print newsletter in InDesign. What I visualize is creating the content online and using an RSS to syndicate the information dynamically to the latest newsletter online and then to Import the RSS into an InDesign template. Is that possible? 
    • Will RSS work as well.
      2005-02-22 09:41:12 
      Hm.... almost, but not quite. RSS is one specific flavour of XML that won't be usable by web browsers and InDesign.

      However, what you could do is create a "master" XML document that contains the content to be used in all 3 sources (the print & online newsletter andwebsite) and then use a one or more XSLT stylesheet(s) to transform the content into the format expected by each source. Send me an email (fvlogic at telus dot net) if you would like to discuss this option further.

      Hope things work out!

  9. InDesign's XML features are not-so-good
    2004-08-24 22:04:03 
    I found it interesting that the InDesign CS Classroom in a Book, published by Adobe Press, makes no mention of XML. It's not even in the index. However, the InDesign 2 Classroom in a Book has an entire chapter on the XML features.

    I think Adobe is backing off on marketing the InDesign XML features because they're really weak. They work for only with very specific workflows that I don't feel are very practical. Adobe has not even addressed fundamental issues such as what to do with overflow text.

    I am a diehard InDesign fan and hate to say it, but Adobe is behind QuarkXPress in terms of XML features.

  10. Table Data Import
    2004-08-11 01:33:56 Bernd Hofner
    I was playing a bit with the InDesign XML import capabilities. It seems to me, that the support for table like data is pretty limited. At least I didn't find an easy way to convert something like:



    into an InDesign table.
    The only way to get a table into InDesign seems structuring my XML data in the proprietary InDesign table export format (I found this clue somewhere in a newsgoup, unfortunatly not in the InDesign documentation).
    This isn't very elegant, because I weaken the distinction between content (XML) and layout (InDesign) by being forced to deliver content that already contains partial layout data. The content becomes cluttered with the layout data and must be targeted especially for InDesign.

    Is there a nicer solution? Maybe it is possible to trigger a InDesign script when importing a new XML file that converts the XML table-like data to a
    InDesgn table layout?



    • Table Data Import
      2005-01-03 04:31:01 
      Hello Bernd,

      yes, I agree, InDesign's XML Table Features are weak.

      If you really need a solution for this, you can use scripting (visual Basic or applescript).
      you can define your own xml-format, apply an xsl-t transformation and build a new or change an existing indesign table while walking throut the resulting DOM-Object.

      I've done this for some customers on a windows platform using visual basic. It's not an easy solution, but if you need the actuality of the indesign documents (for example with new data from a database system) it migth be worth the efforts.


  11. Large documents
    2004-08-06 18:00:06 
    This would be great for large documents like catalogs. 

    We were looking into using a web based CMS to keep track of content (typo3) then exporting XML from the CMS to InDesign to produce printed publications and pdfs. Adobe's documentation was limited and it started to look like it would end up being a pretty brittle system if used on a complex document.

    I would love to hear some success stories on the topic.

    • Automating production XML
      2005-10-20 09:07:35 
      Hi I can help with automated production solutions, contact me on 07919 057213 to discuss.


      • Automating production XML
        2007-01-26 10:59:54 
        Thomas Green. I would love to contact you regarding a catalog project I need help with. I want to use xml data to build inDesign tables automatically. Anyone else who might be able to help should call as well.

        Christian Shubin


    • Those optionally varying graphics...
      2004-12-29 09:46:05 
      I'm a total rookie when it comes to XML but am quickly understanding its power.  In your business card example you mention the ability to include a different graphic with each employee.  Can you expand on this?  I imagine there's a way to get an XML file to refer to an image (jpg? pdf? other?) which would then be embedded into a preformatted box in the .indd -- buy what does the XML code look like?  Simple unix style (../images/graph1.jpg)?  Thank you very much, by the way, for this thorough and easy to follow introduction to XML.  -Matt
      • Those optionally varying graphics...
        2006-06-30 02:48:12 
        Indesign XML works very well with dynamically loading images.
        I am using Indsign 2.0 and the following works fine.
        In Indesign:
        Design the layout with a rectangle frame (the one with a cross on it), right click, define the contents as graphic and give it a tag name ie Image1.

        In XML file:
        Define the tag for Image1 with a href attribute:

        My New Product
        Buy this and you never need anything else again
        This Product gives you the following benifites

    • Large documents
      2004-08-10 05:37:05 
      There are suppliers who offer these kind of functionality. Look at www.mycatt.com, web-based Network Publishing solution. Mycatt links with Indesign and Quark to offer automated DTP and generate high ress publications and pdf's.
      • Large documents
        2006-03-15 15:06:50 
        Looks as if www.mycatt.com has gone away...anyone know what happened to them, if anyone picked up their technology?
  12. InDesign and XML editors
    2004-08-06 13:06:10 
    If you're looking for a followup story, why not explain for those of us for whom XML is a mystery how we can use an XML editor to format documents for input into InDesign.

    I'm constantly needing to format text documents for InDesign and don't particularly like to do it within ID.

    --Mike Perry, Inkling Books, Seattle

    • InDesign and XML editors
      2008-04-20 17:24:35 
      I would love to see a " how to" on the XML data file.
      I have followed through the steps of setting up an Indesign CS2 template as per the Business Card sample, with styles etc. I can find no instructions on how to set up the data to import via XML.
      Any suggestions welcome.


1 to 12 of 12