1.2 XML Advantages

1.2 XML Advantages

This section expands upon the goals for XML data exchange and how they can help you as a FileMaker Pro developer. The recommendations for the design of the Extensible Markup Language show some of the advantages this format offers. These XML design goals can be found in the document "Extensible Markup Language (XML) 1.0 (Second Edition), W3C Recommendation 6 October 2000", http://www.w3.org/TR/REC-xml.

  • XML shall be straightforwardly usable over the Internet.

  • XML shall support a variety of applications.

  • XML shall be compatible with SGML.

  • It shall be easy to write programs that process XML documents.

  • The number of optional features in XML is to be kept to the absolute minimum, ideally zero.

  • XML documents should be human-legible and reasonably clear.

  • The XML design should be prepared quickly.

  • The design of XML shall be formal and concise.

  • XML documents shall be easy to create.

  • Terseness in XML markup is of minimal importance.

1.21 Why XML Data Exchange is Extensible

Common formats currently exist for exchanging data among applications and systems. Text formats may use fixed-length fields or a delimiter such as a comma, tab, or other character between data types. These formats are wonderfully compact, but they were designed for the days when storage was at more of a premium. These formats rarely offer the description of the type of data. Unless a map is included with the data, you will likely have difficulty extracting specific data. For example, one piece of data as a series of numbers could be an identification key, a telephone number, an account number, or several concurrent number data types. These older formats are often limited in what information can be exchanged.

Text Formats in FileMaker Pro

FileMaker Pro can import and export comma-separated values (.csv), tab-delimited text (.tab or .txt), and other formats. If the first row (or record) of the data contains the field names and the data is commaseparated, the format is of merge (.mer) type. ODBC, JDBC, Web Publishing, and XML use the field names for data exchange. You may think of XML publishing in FileMaker Pro as extending the data exchange already available! You can read "About file formats" in FileMaker Pro Help for more information on the formats available for import and export.

With FileMaker Pro 6, data can be exported as XML in one of two formats. The FMPXMLRESULT grammar uses a metadata format to describe the field names. This is somewhat similar to the merge format, which includes the field or column names as the first record. The actual data is placed in repeating row elements with a column element for each field in the export. The other grammar for FileMaker Pro 6 export, FMPDSORESULT, has less information about the fields but uses the field names as the element names. You can read more about these two grammars in Chapters 2 and 4.

Text Formats in XML

XML documents include the description along with the data. Remember that XML is a markup language for creating markup, so you can create whatever descriptions you want. The goal is to create markup that is "sensible" as well as extensible. The document becomes more human readable by including the description. The document also becomes more machine extractable when the description of the content is included. With XML, the map is included with the document.

A typical XML document may have hundreds of markup tags yet can be quickly searched for a particular one. Imagine looking in a document for a customer whose first name is John. A text editor or word processor can perform a fast search, but how would you know that you have found the correct piece of information? Look at the example in Listing 1.3 for the markup for people, then find all the people who are customers. Finally, search for a customer with the first name of John. You have just narrowed down your search in a hierarchical manner.

Listing 1.3: people.xml
Start example
            <company>Paper Cutters</company>
End example

The example in Listing 1.3 shows you another advantage of XML: You can extract only the data you need and ignore extraneous data. If all you want is the customer data, the <customer></customer> elements are used in a search. Another need may be for vendor information and only those elements are used in the search results. This enables many people who need different information to use the same XML document.

Extensible also means "flexible" when using XML. An XML document may provide alternate versions of text. Listing 1.4, greeting.xml, contains explicit text in a variety of languages (xml:lang). Providing alternate content in the same document can make a document flexible for multiple uses. XML is an international standard and provides for the use of non-English text in the documents.

Listing 1.4: greeting.xml
Start example
            <!-- English -->
      <greeting xml:lang="en">Hello World!</greeting>
            <!-- French -->
      <greeting xml:lang="fr">Bonjour Monde!</greeting>
            <!-- Spanish -->
      <greeting xml:lang="es">Buenos dias, Mundo!</greeting>
            <!-- German -->
      <greeting xml:lang="de">Guten tag, die Welt!</greeting>
End example

XML is also flexible in the way document contents can be transformed for multiple uses. Regardless of platform or application (personal computer, portable digital assistant, or Braille printers and readers, for example), the document can be processed for the proper device. Each application can read the same document and interpret the markup differently. Some of these devices and applications can also write XML. This flexibility opens up much greater communication among many applications and devices. The exchange of information is the key!

1.22 Saving Information for the Future

One of the greatest advantages of documents formatted with XML is that these documents will be accessible long after the devices or methods used to create them are gone. Historical creation and storage of data often relies upon proprietary applications and systems to write and read the documents. The meaning of a document may be lost if that system becomes unavailable. Because XML documents can provide descriptions along with the data, these documents will be easier to interpret later.

The XML standards also provide a partial description of how computer applications should process the XML. This process is called parsing. Some processing is done on a server, and some processing is done within an application on a client machine. Adhering to these standards ensures that in the future documents will be just as useful as they are now.