UNDERSTANDING XML


Recall that XML stands for Extensible Markup Language, a programming language that works like HTML to tag items on a page. HTML is used to describe how items should be formatted, and XML is used to define the items themselves. XML is beneficial because it enables you to use information in different documents in different ways, without having to retype it or copy and paste it each time.

An XML tag, or the XML reference to a specific item, can be mapped to particular styles in your document so that when you apply the tag, the item takes on the proper formatting. You can also store XML text in a database so it can be easily accessed and repurposed for any document.

The best way to talk about XML is to use a specific example and walk through how to use it.

Let's say I'm creating a newsletter for my business, a bakery. In each issue of the newsletter, I publish a recipe for one of the items I sell. I've been hired to bake and serve several types of cookies for a wedding shower. As a courtesy, I would like to create recipe cards for the cookies, and I'm looking for an easy way to get the information from my newsletter onto a recipe card, the template of which I already have created.

To use XML to make this job easier, I'll first open an issue of the newsletter that contains a recipe. I then perform these steps:

1.

Open the Tags palette (choose Window, Tags).

2.

Create a new tag by clicking the New Tag button at the bottom of the palette.

Choose View, Structure, Show Structure to open the panel along the left side of your page and see the objects as they are marked. You can create tags and mark your page elements in any order.


3.

The tag name is highlighted when it is created; type a new name describing the item it will be associated with, for example, BakingInstructions. Your XML tag names cannot contain spaces.

4.

Highlight the text or select the item that you want this tag to apply to. In this example, we select the recipe instructions.

5.

Click the tag in the palette to mark itwith the recipe instructions highlighted, we click the BakingInstructions tab in the Tags palette to mark it (see Figure 32.1).

Figure 32.1. Tag the items in your file that you want to export as XML.


6.

Continue creating tags and naming them for the objects in your document, then tagging page elements until all the information you want to use is marked.

7.

Select File, Export. Name your file and choose XML as the Format. Click Save.

Go ahead and create tags for every part of your document, even if you don't think you will need to use that particular piece of information in the document you're creating. As an example, if I include a personal story about every recipe that I publish in my newsletter, I tag the story, even if I don't plan to include it on my recipe card. At some point I might want to publish a cookbook and include the personal stories there. Having the stories already tagged for XML makes it easy to drop them on my cookbook pages when the time comes.


8.

Open a new file or a template you've created for the new file. In this case, we open the template for our recipe card.

9.

Go to File, Import XML. Browse to the XML file you saved in step 7, select it and then click Open.

10.

The Structure pane opens at the left of your new document. Make sure you have created frames for the different page elements in the new document and drag and drop each tag into the proper frame.

All information from the original document is placed in the frame in which you drag and drop the tags (see Figure 32.2).

Figure 32.2. Drag and drop tags from the Structure pane into your new document to place the page objects.


Again, this is a very simplistic explanation of XML; there are many more options available for importing and exporting using this language. A good source of additional information is found on the Adobe website, at http://www.adobe.com/products/indesign/indepth.html.




Special Edition Using Adobe Creative Suite 2
Special Edition Using Adobe Creative Suite 2
ISBN: 0789733676
EAN: 2147483647
Year: 2005
Pages: 426
Authors: Michael Smick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net