Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This
This chapter is from the book Styles and XML

Styles and XML

Until Adobe provides better XHTML mapping capabilities, you can always use XML. XML is a way to identify data based on the type of information it represents. Out of the box, InDesign is second only to Adobe Framemaker in the breadth and depth of its capabilities for importing and exporting XML for print-based documents (FIGURE 10.12). For example, XML can help automate publishing data from spreadsheets and databases; it can dynamically generate documents—like business cards, price lists, and catalogs—much faster than you can by hand; and it can move content quickly and efficiently from one document to another, or even to and from the Web. And best of all, it’s tightly integrated with InDesign’s text-based styles.

Figure 10.12 Most of InDesign’s XML features and interface are hidden when you start the program and must be turned on or made visible.

EXPORTING XML

Successfully exporting XML from InDesign requires a multistep process.

Optimize the layout. The first step is to create a fully styled and completely threaded document similar to the Web-aware layout described earlier in the chapter (see Figure 10.7). This is not only useful for Web-based workflows,
it’s effective for almost any kind of XML application, because logical and well-organized document structures result in logical and well-organized data structures. The car flyer is already converted, so it’s an ideal test case for the process of exporting XML from InDesign.

Build the tags. The next step is to create, or load, a list of XML tags and then apply them to the document content. The ad file doesn’t contain any XML tag names yet, so you need to create them. Tags can be created one by one manually (FIGURE 10.13) or loaded from an existing XML file, InDesign document, or Document Type Definition (DTD).

Figure 10.13 Use the Tags panel to create or load XML tags and assign them to the document content.

What should you name your tags? Almost anything you want, as long as it complies with XML syntax rules, which includes among other things being case-sensitive and using no spaces or special characters.

XML tags are equivalent to HTML code elements except they convey no styling information, only data identity. So, one school of thought suggests you name your tags for the type of data they identify, such as “productname,” “size,” “price,” and so on.

On the other hand, tags can also be applied individually to characters, paragraphs, graphics, and can even be in nested configurations to help better organize and identify components of your content. Since this often mirrors how paragraph, character, table, and object styles are applied, another recommended method is naming XML tags to match the existing InDesign style names. This is especially valuable because InDesign offers a productivity enhancement that can automatically tag text based on how it’s styled.

Apply the tags. Apply tags to each element you want to export. Free-standing frames and graphics that have no tags will not be exported. However, if a text frame contains even one tag, InDesign exports the tagged elements as you would expect but the remainder as untagged text. You can select each frame or range of characters and click on a tag name in the Tags panel to assign it manually. For text, it’s most efficient to have the styles that are already applied to text match up to XML tags by mapping. Choose Map Styles to Tags from the Tags panel menu or the Structure panel menu. If the style and tag names match exactly, case-sensitive and letter for letter, you can save time by choosing the Map by Name option. The mapping feature can even apply tags to text formatted by character styles contained in nested- and GREP-based styling. If your tag and style names don’t match perfectly choose tags manually from the drop-down menus (FIGURE 10.14). Multiple styles can be mapped to the same tag.

Figure 10.14 Correlate styles with tags by choosing matches manually from the drop-down menus, or select the Map by Name option.

When tags are applied to content, there are visual indicators available in the layout. Choose View > Structure and select Show Tag Markers or Show Tagged Frames to see the color-coded overlays and brackets in Normal view mode (FIGURE 10.15).

Figure 10.15 The layout displays visual cues to indicate tagged content.

Export as XML. The Structure pane displays and allows you to manipulate the XML structure within the document. You can drag and drop the elements within the Structure pane to reorganize and resequence as desired for export. Select the root or any of the child elements it contains to specify what will be exported (FIGURE 10.16).

Figure 10.16 The Structure pane shows the XML components and structure of the document.

Now you’re ready to export. You can activate the Export XML command in four ways: from the File menu, from the Structure pane menu, by right-clicking on the root or any of the child elements contained therein, or by pressing Command/Ctrl-E. In the resulting dialog, choose XML from the drop-down menu and name the file. When you click Save, the XML Export Options dialog appears (FIGURE 10.17), allowing you to specify what will be included in the XML output. XML export options are similar to those offered by the XHTML filter with a few exceptions, like the ability to remap certain types of characters and to apply an XSLT transformation of the data during output (see the section “XSLT: Styles on Steroids”).

Figure 10.17 XML export settings for text and images.

  • + Share This
  • 🔖 Save To Your Account