![]() ![]() ![]() ![]() ![]() ![]() ![]() |
|||||
|
|
|||||
| XML to HTML conversions: implicit hypertext | |||||
| Introduction: XML to HTML conversions: implicit hypertext |
Sample
This program uses the mart.xml sample input file.
down-translate with xml ; Use XML parser.
global counter chap-no initial {0}
element #implied
output "%c"
element title when parent is doc
local stream title
set title to "%c"
output "<title>%g(title)</title>%n" || "<h1>%g(title)</h1>%n"
element audience
output "<b>For:</b> <i>%c</i>%n"
element p
output "<p>%n%n%c"
element glossary
output "%n%n<hr><h2>Glossary</h2>%n%n" || "<ul>%n%c" || "</ul>%n"
element term
local stream term
set term to "%c" ; Content linking.
output '<a name="content-%g(term)">' || "<li>%g(term):"
element part
local stream part
set part to "%c"
output '<a href="#content-%g(part)">' || part || '</a>'
element defn
output " %c%n"
; Explicit links.
element xref
output '<a href="#exp-%v(idref)">'
|| referent "exp-%v(idref)"
|| '</a>%c'
element chapter
output "<hr>"
increment chap-no
output '<a name="exp-%v(id)">%n%c'
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
set referent "exp-%v(id)" to chap-title
document-end
;
; Some browsers don't link well to things at the bottom of
; a page, so put in extra blank lines.
;
output "<br>" ||* 45
|| "<center><i>The End</i></center>%n"
| ---- |