Using lingoSchema.xml

Processing lingo.xml and the globalized XML template files involves the use of a schema to define the content (both elements and attributes) and structure of both XML documents. An XML schema performs many of the same functions as a DTD, such as defining and validating the elements and attributes that can exist in a class of document, but an XML schema also offers the following advantages:

These features make XML schemas far more flexible and extensible than DTDs.

The PT application uses an XML schema in the XML merge process to make the operation of inserting values in lingo.xml elements into elements in the globalized XML template files more efficient. The lingo.xml file uses lingoSchema.xml to declare the LID as an id data type. This enabled the LitWare designers to use the nodeFromID method for an indexed search through the lingo.xml file instead of the SelectSingleNode method, which uses a much more resource-intensive pattern match. See NodeFromID vs. SelectSingleNode for a discussion of these methods. You can think of the reference to a schema that declares an attribute as a data type as analagous to early binding. Because of the reference to the schema, the application intrinsically knows what a LID means.

The following line of code from lingo.xml references lingoSchema.xml:

<UIElement CHARSET="ISO-8859-1" CODEPAGE="1252" xmlns="x-schema:LingoSchema.xml">

In lingoSchema.xml, the following code references the namespaces from which the schema inherits. The "xmlns:dt" string references the datatypes namespace. Every attribute permitted in the elements in this schema is declared in <AttributeType> elements. See Designing the Lingo Files for a list of the elements defined in and validated by lingoSchema.xml. The globalized XML template files do not reference lingoSchema.xml. The search the NodeFromID method conducts occurs in lingo.xml; also, the XML template files contain HTML elements that would make the schema unnecessarily complicated for the function it performs in the PT application.

<Schema name="LingoSchema" xmlns="urn:schemas-microsoft-com:xml-data" 
       xmlns:dt="urn:schemas-microsoft-com:datatypes">
   <AttributeType name="CHARSET" dt:type="string" />      
   <AttributeType name="CODEPAGE" dt:type="string" />
   <AttributeType name="LID" dt:type="id" required="yes" />
   <AttributeType name="L_NAME" dt:type="string" />
   <AttributeType name="title" dt:type="string" />
   <AttributeType name="value" dt:type="string" />  
   <AttributeType name="maxLength" dt:type="int"/>  
   <AttributeType name="accessKey" dt:type="string" />
   <AttributeType name="alt" dt:type="string" />  
   <AttributeType name="src" dt:type="string" />  
   <AttributeType name="language" dt:type="string" />   
   <AttributeType name="placement" dt:type="enumeration" dt:values="innerHTML innerText beforeBegin afterBegin beforeEnd afterEnd"/>
………………
<ElementType name="TITLE" content="textOnly" model="closed"> 
      <attribute type="LID" />
      <attribute type="placement" />
   </ElementType>
………………
</schema>

For detailed discussions of XML Schema and XML Schema Reference see the Microsoft XML Developer Center, available online at the MSDN™ Web site.