130 likes | 228 Views
Using XML, XSLT, and CSS in a Digital Library. Rendering Using XSLT and CSS Mathematics Rendering Thomas Habing thabing@uiuc.edu ASIS Annual Meeting 2000. Evolution of Rendering. Full-text ‘96 Plugins: Adobe Acrobat (PDF) or Softquad Panorma (SGML)
E N D
Using XML, XSLT, and CSS in a Digital Library Rendering Using XSLT and CSS Mathematics Rendering Thomas Habing thabing@uiuc.edu ASIS Annual Meeting 2000
Evolution of Rendering • Full-text • ‘96 Plugins: Adobe Acrobat (PDF) or Softquad Panorma (SGML) • ‘99 Custom Server-side Converter to DHTML • ‘00 Standards-based XSLT Converter to DHTML • Metadata • ‘96 OpenText Livelink for short & long citations • ‘98 Merged with full-text • ‘99 XSLT for long citations • ‘00 Migrating to XSLT for long & short citations • Including special characters, formatting, and math ASIS Annual Meeting 2000
XSLT Where Should It Happen • Client-side • IE5+ only • Not Netscape 6 or Mozilla (yet) • IE5 not yet fully compliant w/ XSLT and XPath standard • Can reduce the load on your servers • But performance on low-end clients can be BAD • Server-side • Performance could be a problem on busy servers, serving large, complex documents • More control & flexibility over the conversion (metamerge) • Offline Preconversion • Best performance • Not best for dynamic documents (metamerge) ASIS Annual Meeting 2000
Transform Source XML into HTML or ‘Renderable’ XML? • Our current choice is HTML (XHTML) • Many browsers do not support XML at all • Even of the browsers that do support XML, they still support HTML better • Images, Linking, Tables, CSS, etc. • As there is more support for additional XML standards, such as XLink, this may not always be the case • Even for ‘renderable’ XML, we still need to revert to embedded HTML for some constructs • Eliminates the need to for dual code maintenance ASIS Annual Meeting 2000
Converting XML to HTML • Simple one-to-one conversions:<sect> becomes <span class="sect"> • span.sect {display:block;margin-left:2em} • Attribute based conversions:<emph type="1"> becomes <span class="emph_1"> • span.emph_1 {font-style:italic} • Generated text, such as punctuation:<ag><au>Tom</au><au>Tim</au><au>Bob</au></ag>becomesTom, Tim, Bob. • Rearranged children:<au><sn>Habing</sn><fn>Tom</fn></au>becomesTom Habing ASIS Annual Meeting 2000
Converting XML to HTML (cont.) • Some elements are converted into HTML elements other than <span> or <div> • Figures are converted to <img src="…"> tags. • Internal links with ID and IDREF attributes are usually converted into HTML anchor tags. • Table elements are converted into corresponding HTML <table>, <tr>, or <td> tags. • ‘Real’ DTDs require some fairly complex processing. • So far XSLT seems to be able to handle nearly every case we have come across • However, some cases have required JScript extensions to XSLT ASIS Annual Meeting 2000
Alternates to XSLT • Custom Parser (our previous approach) • SAX - Simple API for XML • Performance can be better for large XML files • Streaming parser - entire document is not loaded into memory as with XSLT • Not as flexible as XSLT • More difficult to rearrange output • Not a W3C standard ASIS Annual Meeting 2000
Rendering Mathematics • SGML ISO 12083 or variant • Convert to DHTML for native browser rendering • Convert to an Image • Convert to MathML and... • Render as above, but only one target • Render with a Plugin (techexplorer, WebEQ) • Native browser support (Mozilla or Amaya) • TeX • Convert TeX to Image (tex->dvi->ps->gif) • Render with a Plugin (techexplorer) ASIS Annual Meeting 2000
Rendering SGML Math as DHTML • XSLT Dynamically Converts Markup to HTML with: • CSS Positioning • JavaScript • Dynamic Properties • Center Vertically:top:expression((this.offsetHeight-8)/2+'px'); • Set the width:width:expression(Math.max( this.parentNode.children(1).offsetWidth, this.offsetWidth)+'px'); • Attached Behaviors • behavior:url(center.htc); • Currently only works with Microsoft IE 5+ ASIS Annual Meeting 2000
Math Example Using DHTML span.fr {position:relative;width:1px;margin-top:expression(-(this.children(1).offsetHeight-8) +'px’);top:expression((this.children(1).offsetHeight-8) +'px’);} div.nu {border-bottom:1px solid black;text-align:center;behavior:url(nu.htc);} div.de {text-align:center;behavior:url(de.htc);} <fr> <nu>1</nu> <de>2</de></fr> <span class=‘fr’> <div class=‘nu’>1</div> <div class=‘de’>2</div></span> ASIS Annual Meeting 2000
Convert SGML Math to Image • Need to support less capable browsers • How to convert? • Display document in Internet Explore as DHTML • Hide irrelevant information leaving only the formula • Resize the display window to fit in the formula • Trim blank and check if there is unknown symbol • Capture the display window and convert the image to GIF/JPEG format. • Process is fully automated (Visual Basic) ASIS Annual Meeting 2000
Rendering MathML • Original PDF from publisher: • Custom DHTML: • Mozilla M18: • Techexplorer(Netscape): • Amaya: ASIS Annual Meeting 2000
Rendering Issues • Special Character Support • STIX • Unicode • Publisher Specific Entities • Mathematics • Better Native Browser Support for MathML • Conversion of Legacy Math to MathML ASIS Annual Meeting 2000