Specifications

Data Translators 235
The following example shows the locked portion of code that might be generated from the
translation of the server-side include
<!--#include virtual="/footer.html" -->:
<MM:BeginLock translatorClass="MM_SSI" type="ssi" ¬
depFiles="C:\sites\webdev\footer.html" orig="%3C!--#include ¬
virtual=%22/footer.html%22%20--%3E">
<!-- begin footer -->
<CENTER>
<HR SIZE=1 NOSHADE WIDTH=100%>
<BR>
[<A TARGET="_top" HREF="/">home</A>]
[<A TARGET="_top" HREF="/products/">products</A>]
[<A TARGET="_top" HREF="/services/">services</A>]
[<A TARGET="_top" HREF="/support/">support</A>]
[<A TARGET="_top" HREF="/company/">about us</A>]
[<A TARGET="_top" HREF="/help/">help</A>]
</CENTER>
<!-- end footer -->
<MM:EndLock>
A simple block/tag translator example
To better understand translation, its helpful to look at a translator that is written entirely in
JavaScript (that is, one that does not rely on a C library for any functionality). The following
translator would be more efficient if it was written in C, but the JavaScript version is simpler,
which makes it perfect for demonstrating how translators work.
As with most translators, this one is designed to mimic server behavior. Assume that your web
server is configured to replace the
KENT tag with a different picture of an engineer, depending on
the day of the week, the time of day, and the users platform. The translator does the same thing,
only locally.
<html>
<head>
<title>Kent Tag Translator</title>
<meta http-equiv="Content-Type" content="text/html; charset=">
<script language="JavaScript">
/**********************************************************
* The getTranslatorInfo() function provides information *
* about the translator, including its class and name, *
* the types of documents that are likely to contain the *
* markup to be translated, the regular expressions that *
* a document containing the markup to be translated *
* would match (whether the translator should run on all *
* files, no files, in files with the specified *
* extensions, or in files matching the specified *
* expressions). *
**********************************************************/
function getTranslatorInfo(){
//Create a new array with 6 slots in it
returnArray = new Array(6);