Share this Page URL
Help

Chapter 7. Importing and Exporting > The Best of All Possible Worlds - Pg. 673

Importing and Exporting 673 Transforming XML with XSL Putting all of your data into XML presents a problem--how the heck do you get it into a form that people can look at it? InDesign is certainly one answer, but there's another, and that's XSL. XSL, or Extensible Stylesheet Language, exists to transform XML into other formats. Once upon a time, there was only one Web browser (Mosaic), which ran on a single type of device (a computer). HTML did a reasonably good job of displaying data (Web pages) in that browser on that device. But the Web grew. These days, we have multiple browsers (Netscape Navigator, In- ternet Explorer, Opera) running on multiple platforms (telephones, Palm OS devices, Windows, the Mac OS, television sets). An HTML format that works well for one of these viewing environments probably won't work for the others. So Web site developers faced a problem: how could they avoid writing and maintaining multiple versions of their HTML pages? The answer lies in the combination of XML and XSL. When you use XSL, you can store the data that makes up your Web pages as XML and transform it into HTML appropriate for viewing on whatever device and browser happens to be connecting to your Web site. If you do this, you need to write and maintain the XSL templates, but the templates change far less frequently than your Web pages. XSL is made up of two main parts: XSL Transformations (or XSLT), which comprise the transfor- mation language itself, and XML Path Language (or XPath), a way to locate data in XML. At this point, you're probably scratching your head and wondering just exactly what a language for transforming XML into HTML has to do with InDesign. It's this: XSL can transform XML into any text format, including plain text, PDF, PostScript, HTML, other forms of XML, and, our favorite, InDesign tagged text. Why use XSL to transform XML before placing it in an InDesign document? Well, that depends on your workflow. If you need to import lots of tabular data from your XML files, converting to tagged text first can speed things up, because tables imported from XML appear in InDesign's default table formatting. This usually means that you'll have to select and reformat each table--a task that can be time-consuming, to say the least. If you transform the same XML file to tagged text using XSL, you can specify every attribute of the tables in the file. To further encourage you to "think outside the box," we'll post an example on David's Web site (www.moo.com/rwid/). We hope you'll make the trip to download the examples and check them out, because the combination of InDesign, XML, and XSL is a very powerful and useful way to work with publications. The Best of All Possible Worlds Can you get there from here? When you're working with InDesign, you can almost always export or save files in a form you can use in another program, and you can usually produce files in other programs you can import or open using InDesign. There are definitely bumps in the road--some- times, you've got to go through an intermediate program to convert files from one format to another (particularly if the files came from another type of computer). Someday, we'll have a more complete, universal, and sophisticated file format for exchanging pub- lications. PDF is getting very close to being that format, and it's certainly making steps in the right direction. When the great day arrives, we'll be able to take page layouts from InDesign to FreeHand to QuarkXPress to Photoshop, using each program for what it's best at without losing any formatting along the way. And the streets will be paved with gold, mounted beggars will spend the day ducking winged pigs, and the Seattle Mariners will win the World Series.