[Previous] [Contents] [Next]


Delivery to Multiple Media


Information needs to be published via different media: on the Web, in hard copy, on CD-ROM, as help files, and so on.

For delivery on the Web, HTML will still be in place for awhile. But which type of HTML: version 3.2, version 4, DHTML Microsoft flavor or DHTML Netscape flavor?

Until now you had these choices:

Use only those HTML tags that are supported by all browsers (the common denominator approach).
Make browser-specific optimized HTML pages.
Include scripts in your HTML pages to generate browser-specific code.

With XML, you can use another tactic. You can check which browser is asking for information and transform your XML data on-the-fly to the most appropriate version of HTML.

The big advantage of this approach is that you have to manage just one source file. All formatting and processing is kept separate from your data. This means that if a new flavor of HTML arrives, you need to write a new conversion but your data doesn't need to be modified.

For getting to hard copy, you can convert your XML data to RTF (Rich Text Format) for use with Microsoft Word, or to another markup language used in other text processing tools (for example, MIF for FrameMaker).

The XML file in Listing 14.1 can be used as source code for generating RTF output.

Listing 14.1 musicians.xml-Your XML File to Convert
 1: <?xml version="1.0"?>
 2: <!DOCTYPE musicians [
 3: <!ELEMENT musicians  (musician)+ >
 4: <!ELEMENT musician  (name, instrument, NrOfRecordings)>
 5: <!ELEMENT (name, instrument, NrOfRecordings)  (#PCDATA)>
 6: ]>
 7: <musicians>
 8:   <musician>
 9: <name>Joey Baron
10: </name>
11: <instrument>drums
12: </instrument>
13: <NrOfRecordings>1
14: </NrOfRecordings>
15:   </musician>
16:   <musician>
17: <name>Bill Frisell
18: </name>
19: <instrument>guitar
20: </instrument>
21: <NrOfRecordings>3
22: </NrOfRecordings>
23:   </musician>
24:   <musician>
25: <name>Don Byron
26: </name>
27: <instrument>clarinet
28: </instrument>
29: <NrOfRecordings>2
30: </NrOfRecordings>
31:   </musician>
32:   <musician>
33: <name>Dave Douglas
34: </name>
35: <instrument>trumpet
36: </instrument>
37: <NrOfRecordings>1
38: </NrOfRecordings>
39:   </musician>
40: </musicians>

This could become the RTF file in Listing 14.2.

This is just one example of how XML can be converted to another markup language. How to do it will be discussed during the next few days.
Listing 14.2 musicians.rtf-The RTF File After Conversion
 1: {\rtf1\ansi\ansicpg1252\uc1
 2:
 3: ... //lots of rtf code deleted
 4:
 5: \pard\plain \s18\li1440\sb320\widctlpar
 6: \adjustright \b\f15\fs28\lang2057\cgrid {Joey Baron
 7: \par }\pard\plain \s19\li2880\sb120\widctlpar
 8: \adjustright \f15\fs20\lang2057\cgrid {drums
 9: \par }\pard\plain \s20\li3600\sb120\sa400\widctlpar
10: \adjustright \i\f15\fs20\lang2057\cgrid {1
11: \par }\pard\plain \s18\li1440\sb320\widctlpar
12: \adjustright \b\f15\fs28\lang2057\cgrid {Bill Frisell
13: \par }\pard\plain \s19\li2880\sb120\widctlpar
14: \adjustright \f15\fs20\lang2057\cgrid {guitar
15: \par }\pard\plain \s20\li3600\sb120\sa400\widctlpar
16: \adjustright \i\f15\fs20\lang2057\cgrid {3
17: \par }\pard\plain \s18\li1440\sb320\widctlpar
18: \adjustright \b\f15\fs28\lang2057\cgrid {Don Byron
19: \par }\pard\plain \s19\li2880\sb120\widctlpar
20: \adjustright \f15\fs20\lang2057\cgrid {clarinet
21: \par }\pard\plain \s20\li3600\sb120\sa400\widctlpar
22: \adjustright \i\f15\fs20\lang2057\cgrid {2
23: \par }\pard\plain \s18\li1440\sb320\widctlpar
24: \adjustright \b\f15\fs28\lang2057\cgrid {Dave Douglas
25: \par }\pard\plain \s19\li2880\sb120\widctlpar
26: \adjustright \f15\fs20\lang2057\cgrid {trumpet
27: \par }\pard\plain \s20\li3600\sb120\sa400\widctlpar
28: \adjustright \i\f15\fs20\lang2057\cgrid {1}{\f2\lang2067\cgrid0
29: \par }\pard\plain \widctlpar\adjustright \fs20\lang2057\cgrid {
30: \par }}

This file can be read by Microsoft Word and most other word processing software.

[Previous] [Contents] [Next]