|
|||||
XML to HTML conversions: linking based on implied structure | |||||
Related Concepts |
Introduction
Linking based on implied structure in this type of conversion is fairly uncomplicated, especially when dealing with a book metaphor for the XML input file. This sample describes how to create a secondary table of contents (implied by the intended audience for each book chapter).
The first step is to specify where you want the secondary table of contents to appear by writing a referent to that location (even though the value hasn't been determined yet):
element author output "by: %c%n"
This is where we want the table of contents to go:
output "<hr><h2>Table of Contents</h2>%n" || '<ul>%n' || referent "toc" || '</ul>'
This is where the contents by audience should go:
output "<hr><h2>Contents by Audience</h2>%n" || '<ul>%n' || referent "cba" || '</ul>'
Then, for each new audience, you would write data (specific to that audience) to the original referent (the content by audience listing). For each chapter encountered, you would write the necessary linking information to the referent associated with that chapter's audience. OmniMark takes care of putting the appropriate information in the right place.
element audience local stream aud set aud to "%c" output "<b>For:</b> <i>%g(aud)</i>%n"
Handle contents by audience and give it a starting value:
do when referents hasnt key "audtype-%g(aud)" set referent "audtype-%g(aud)" to "<li>%g(aud): "
Put a place for this list of audience references in the contents by audience referent. Or, if a referent for this audience exists, just append the desired delimiter (a semicolon in this case).
put cba referent "audtype-%g(aud)" else set referent "audtype-%g(aud)" to referents ^ "audtype-%g(aud)" || "; " done
Next write the necessary linking information to the end of that audience's referent:
using attribute id of parent set referent "audtype-%g(aud)" to referents ^ "audtype-%g(aud)" || '<a href="#exp-%v(id)">%g(chap-title)</a>%n'
Related Concepts
XML to HTML conversions |
---- |