Brisbane Handout

Download Brisbane Handout

Post on 21-Feb-2015

38 views

Category:

Documents

17 download

Embed Size (px)

TRANSCRIPT

IDUG

Brisbane, Qld 14 August 2008

XML & InDesignCari Jansen cjansen@typefi.com

How To Build an InDesign XML runin template for repeating elementsLets have a brief look at an example and how you could develop an InDesign template for automated XML run-in of repeating elements.

Figure 2. Adding an element to the Structure.

Figure 1. Reviewing the structure of a design and assigning tags to content.

One thing to keep in mind is that the XML list of car-dealers, when imported, will end up as text in a Text Frame. The default tag for a Text Frame or series of threaded text frames (a story) in case of a multi page or listing, is you guessed it the Story tag. This tag is a child tag, which means it is nested within the root tag. In the Structure panel that is indicated by the indentation. The Story element itself will be the parent of all other elements. When you are basing the development of the InDesign run-in template on a sample document youve created, you can automatically add the Story element to the Tags panel and tag the Text Frame instead of first adding a new Tag to the Tags panel, then adding this element to the Structure.Automatic Tagging

The design

Give your data meaningful names, in the Tags panel youd add new tags for each of the XML elements. Consider using a DTD Document Type Definition, to quickly insert all of the possible tags into the Tags panel without making any typos. DTDs also enable you to validate the XML structure you create, or that is imported during XML import, against rules set in the DTD. For example a rule could be that a Dealer may must have nested elements for brand name, description, office details, phone listed in a fixed order. If you are going to Map tags to styles as part of your template design, it is probably a good idea to create matching Tag and Style names in the template, as it makes adding the Tags to the panel an easier task.Building the structure

Why tag things manually when we can do things on-the-fly right? Select the Text Frame containing your single car dealer design content, and click the Autotag icon at the bottom of the Tags panel, or select Autotag from the panel menu.

With the design element finished, youre ready to get started with the build of the Structure and template. If preferred, select the original Root tag in the Tag panel and rename it to your preferred name. The new name automatically updates the Root element name in the Structure panel. To view the Tags panel, select Window > Tags. Double click the Root tag and rename it.

Figure 3. Auto Tag Story

2008- Cari Jansen XML & InDesign IDUG, Brisbane, Qld

2

The Story Element is automatically added to the Structure panel and the Text Frame is now tagged. If the Tag thats added carries another name, then the default tag for Stories has been changed for the document youre working on. To verify InDesigns four default tags used for Story, Table, Cells and Images, select Tagging Preset Options from the Tags panel menu.

Figure 4. InDesigns default Tagging Preset Options.

Ok, weve added one tag, but what about the rest of the XML elements that need to be inserted?New tags

Figure 5. Tags panel.

At this stage the Tags panel displays only the DealersList and Story tags. We need to add quite a few additional tags. When youre working with repeating elements, as is the case in this example, you would add a Tag to your Tags panel for the element that is the repeated element. In this example that is the dealer element, as you are going to use this template to run-in a list of all of the individual dealers for different brands of cars.

To add a new tag for the dealer, select New Tag from the Tags panel menu or click the New Tag icon at the bottom of the panel. Name the Tag dealer.Importing a DTD

I just remembered isnt it easier to use a DTD to add all the tags to the InDesign file? Rather than choosing the New Tag command each time, to insert a new tag? Absolutely! So lets add the remainder of the tags used in this example by importing a DTD. Assuming you have a valid DTD available, select Load DTD from the Tags panel menu and navigate to the .dtd file and click open... and all of the tags defined as part of the DTD are available An easy way to build the rest of the structure for your template and mark-up your template is to highlight content, then apply a tag.Applying tags

First we need to highlight all of the content of the repeating element youre working on, next click the repeating element tag (dealer) in the Tags panel to apply it.

2008- Cari Jansen XML & InDesign IDUG, Brisbane, Qld

3

Continue to do this until youve completed the tags. Any text that needs to automatically be inserted as a prefix or suffix of a Tag, must be placed fully outside the tags. In my example that is the sentence your local dealer and the prefix Phone: Once completed, you can replace the sample text with more relevant text for the template.

Figure 8. InDesign template design completed and ready for import of XML. Figure 6. Applying the repeating element tag to selected content.

The element will automatically nest below the Story element. Next, based on the notes on which tags are going to be assigned to what text in your sample, highlight each of those components. I often work in the story editor when doing this as it much easier to see the tags that are marking up your sample content. To see the tags in the Story Editor ensure the Show Tag Markers is enabled from the View > Structure. Also enable Type > Show Hidden Characters, as it is easier to see if you have paragraph returns and other hidden characters selected when you are building your InDesign template. Remember that your XML does not include paragraph returns and if you want the XML to run-in and replace some of your dummy text, its probably best to exclude the paragraph returns when selecting text to be marked with a tag. Doing so will ensure that during run-in those paragraph returns are inserted as per their position in the template.

Import XML

Youve now created a working InDesign template and can test it with some sample XML. To test the repeating elements function, create a small sample XML file that is extracted from the longer one and Import the XML, then review if you need to make any changes to your template. To import XML, select File > Import XML or select Import XML from the Structure pane menu. Ensure that you enable Clone repeating text elements in the XML Import Options and Do not import contents of whitespace-only elements options, and if you only want to import elements that match the structure you created in your template enable this setting as well. If you the XML file youre importing contains a reference to an XSLT or if youve been supplied an external XSLT you can apply this during import as well. Most often XSLTs are used to transform any kind of XML to XML that is conform specified requirements. It can leave out elements from the source XML that are redundant and it can be used to sort XML content during import. For instance, in the scenario above, you might want to sort the XML by brand name during import.Validate XML

Figure 7. Applying a tag to selected content.

Next youre ready to continue marking up the rest of the text, in the story editor highlight the bits of text that are part of the template design and click the matching Tag in the Tags panel.

Because we imported a DTD earlier as part of our template, we can validate the XML weve imported against this DTD. To validate XML against a DTD, select Validate from the Structure pane menu. Validation can be applied from the Root element, which is the top-most element or from any selected element. Where validation fails red markers flag invalid Elements in the Structure and a list of validation errors with suggested fixes is listed at the bottom of the Structure pane.

2008- Cari Jansen XML & InDesign IDUG, Brisbane, Qld

4

Sample XML Alfa Romeo Visionary innovation meets exhilirating performance Alfa Romeo is an Italian automobile manufacturer founded in 1910. Alfa Romeo has been a part of the Fiat Group since 1986. The company was originally known as A.L.F.A., which is an acronym for Anonima Lombarda Fabbrica Automobili (translated: Lombard Automobile Factory, Public Company). Alf Barbagallo Motors, 354 Scarborough Beach Road, Osborne Park WA 6017 08 9231 5999 Audi Text here Text here. dealers name here, Name, Address here 00 0000 0000

2008- Cari Jansen XML & InDesign IDUG, Brisbane, Qld

5

Additional NotesMapping tags to stylesFigure 10. Example of Image element with reference to image location

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 Styles from 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.

Image reference examplesImages stored in same folder as xml file images stored in a sub folder inside the same folder as xml file Images stored anywhere and referenced by accessing the full path name. This is referred to as an absolute path name

href=file:///image.jpg href=file:///foldername/image.jpgIn the Documents folder on your PC:

href=file:///C:/Users/username/ Documents/RestOfPath/image.jpgIn the Documents folder on your Mac:

href=file:///Users/username/ Douments/RestOfP