|        | |||||
|  | |||||
| XML to HTML conversions: linking based on structure | |||||
| Related Concepts | 
Introduction
This sample describes how to create a table of contents for the chapters of a book. The first step would be to define a referent and open it as a stream:
              global stream toc
              process-start
                    open toc as referent "toc"
Then, at the point you'd like the table of contents to appear, output the referent (even though its value hasn't yet been assigned): 
             element author
               output "by: %c%n"
This is where the table of contents will go:
               output "<hr><h2>Table of Contents</h2>%n"
                   || '<ul>%n'
                   || referent "toc"
                   || '</ul>'
           
Then append the relevant linking to the table of contents referent whenever you happen to encounter it:
               element title when parent is chapter
               local stream chap-title
               set chap-title to "Chapter %d(chap-no), %c"
               output "<h2>%g(chap-title)</h2>%n"
               using attribute id of parent
                 do
                   set referent "exp-%v(id)" to chap-title
                   put toc '<li><a href="#exp-%v(id)">%g(chap-title)</a>%n'
                 done
| Related Concepts XML to HTML conversions | 
| ---- |