|
|||||
XML to HTML conversions: chunking | |||||
Related Concepts |
Introduction
In many XML implementations, a single XML document can be extremely large. This is commonly the case when a book metaphor is used to model and represent information. When delivering to the Web, however, you usually won't want to deliver the paper equivalent of a 500-page document as a single HTML file (even when it makes sense to author it that way internally).
To handle the relatively slow speeds of the Internet, you need to "chunk" the original information into bite-sized pieces for downloading to the final client application. Different applications might require different levels of chunking (chapter, section, volume, etc), depending on the tradeoffs between connection speed and relative usability of the chunks.
The following sample code creates a new file for every chapter encountered. It also adds forward and backward linking to improve navigation. The "chunking" is done easily: whenever a new chapter is encountered, a new file is created for that chapter.
element chapter increment chap-no set file "chap-%d(chap-no).htm" with referents-allowed to '%c'
For chunking out the chapters, this is the only change necessary. All remaining rules that correspond to elements contained within chapters don't need to be changed: their output will, by default, go into the new file.
A similar method would be used for a book glossary; no changes would be necessary to the rules that correspond with a glossary's subelements:
element glossary set file "gloss.htm" to "<h2>Glossary</h2>%n%n" _ "<ul>%n%c" _ "</ul>%n"
The linking mechanisms also need to be changed slightly to refer to the new file linking (and not just locations within a single file).
Related Concepts
XML to HTML conversions |
---- |