Implementing XML in Lingo and Globalized Template Files

Each language directory (en-us, de, and ja) contains a file named lingo.xml. This file contains the localized strings the PT application uses to present user interface text for the locale specified by the browser. This is the XML data used in the XML merge process. The XML merge process takes the strings stored in lingo.xml and inserts them into corresponding elements in the globalized XML template files. The elements in the template files are empty; they are populated by the data stored in the lingo.xml files.

The resulting files are saved as HTML files in the directory for the language of the requesting browser. In the lingo.xml files and the globalized XML template files, the code looks very much like HTML. Compare this to the *menu.xml files, which are converted to HTML with XSL, a very different process in which the data stored in the *menu.xml files receives markup instructions. Menus and menu items are not native HTML elements. The menus in the PT application are built from HTML elements such as DIVs, TDs, TRs, and OBJECTs. XML enables these HTML elements to be assembled into the semantic construct of a menu.

The semantics of the lingo.xml files and the globalized XML template files coincide with the semantics of HTML. For the XML merge process to work, the XML adds a custom attribute, LID, in each element. LID attributes exist in both the XML template files and in the lingo.xml files. During the merge, the Lingo object uses the XML Document Object Model (XML DOM) to walk the trees of each file and locate each element in the lingo.xml file that has the same LID as an element in an XML template file. The Lingo object then inserts the content of the element from lingo.xml into the element in the XML template file.

The following code shows XML from two files that have the same LID. In the first code fragment, which is from ActivityType.xml, notice that there are two <LABEL> elements and an <INPUT> element. Only elements containing visible interface text have LID attributes. The labels do not require attributes in addition to the LIDs, but the <INPUT> elements do. These attributes, which are common to all locales the PT application supports, are stored in the XML template file.

<TABLE border="0" cellPadding="1" cellSpacing="1" dataPageSize="1" dataSrc="#xmldso" width="100%">
            <TBODY>
               <TR>
                  <TD class="Label" colSpan="2" noWrap="-1" width="75%">
                     <LABEL LID="lbl19"></LABEL>
                  </TD>
               </TR>
               <TR>
                  <TD class="LabelSmall" noWrap="-1">
                     <LABEL class="LabelBold" LID="lbl20"></LABEL>
                  </TD>
                  <TD>
                     <INPUT dataFld="Name" maxLength="50" name="Name" onkeypress="setDirty()" tabIndex="1" size="20" style="WIDTH: 100%" LID="inp20" required="true" validator="isWord" />
                  </TD>

The following code contains the XML elements in lingo.xml that correspond to the elements in the preceding XML template file. If you compare the <INPUT> elements in the XML template file and the lingo.xml file, the lingo.xml file contains locale-specific attributes, such as access keys or the maximum lengths of strings that users can enter.

<LABELS>
<LABEL LID="lbl19">Activity Type Information</LABEL> 
   <LABEL LID="lbl20">Activity Type <U>N</U>ame:</LABEL> 
</LABELS>
    
    
<INPUTS>
 <INPUT LID="inp20" L_NAME="Name" MAXLENGTH="50" ACCESSKEY="n" TITLE="Maximum length 50 characters."/>
   
</INPUTS>

The following code is the HTML in activity.htm that results from merging activity.xml and lingo.xml:

<table WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="1" DATASRC="#xmldso" DATAPAGESIZE="1">
   <tr>
       <td colspan="2" class="Label" nowrap width="75%"><label LID="lbl19">Activity Type Information</label></td>
   </tr>
   <tr>
      <td class="LabelSmall" nowrap><label class="LabelBold" LID="lbl20">Activity Type <u>N</u>ame:</label></td>
      <td><input name="Name" style="WIDTH: 100%" TITLE="Maximum length 50 characters." tabIndex ="1" accessKey="n" DATAFLD="Name" maxlength="50" onKeypress="setDirty()"
           LID="inp20" L_NAME="Name" validator="isWord" required="true"></td></tr>
   <tr>

See Designing Globalized XML Template Files and Designing the Lingo Files for a discussion of these two types of XML files. Nonlocalized XML File Elements contains a complete list of the LID attributes used by the PT application.