What's missing from XML? | Tcl is a great match for XML | C++ and Java | What's available today | Related information

XML is poised to revolutionize the way that applications and enterprises exchange information, but in order to reach its maximum potential it needs a scripting language like Tcl. This page describes what is missing from XML and why Tcl is the perfect complement to provide these missing functions.

Tcl and XML

What's missing from XML?

XML is a data representation: it provides a powerful and flexible way of representing many different kinds of structured data. However, by itself XML is static. It has no operational or functional component, so it can't actually do anything.

In order for XML to be successful, it must be integrated with other enterprise resources. XML documents must be created by extracting data from existing applications. XML documents must be translated into other formats and data must be passed from XML documents to other applications. All of these operations require a functional capability; in other words, they need a programming language.

Tcl is a great match for XML

Fortunately, scripting languages such as Tcl have just the right set of features to fill XML's need for programming. Here are a few reasons why Tcl and XML make sense together:

String manipulation. XML is a textual representation, so both creating and processing XML documents involve string manipulation. Tcl is a string-oriented language with a rich set of string facilities such as case conversion, pattern matching, and automatic conversion to and from other formats such as numbers.

Mixing scripts and XML. In many cases the easiest way to create and manipulate XML is with small scripts associated with bits of XML. The easiest way to process an incoming XML document is to attach scripts to elements in a template document. When a real document is received, its elements are matched against the template; for each element in the incoming document, if there is a script associated with the corresponding element in the template then that script is invoked. For example, one script might be invoked for each element named employee.

One of the simplest ways to generate an XML document is to have an XML base document and then supply scripts to fill in various parts of the base document with dynamic data. Tcl is well-suited to each of these styles: Tcl scripts are strings, so it is easy to mix them with other textual content such as XML. It's also easy to write small self-contained scripts in Tcl, whereas most other languages require large amounts of boilerplate for each distinct program. No other programming language can intermix with XML as easily as Tcl.

Unicode. XML uses Unicode as its text representation in order to accommodate all of the languages of the world. Tcl uses Unicode as its internal representation so all of the Tcl string facilities, such as pattern matching, support the full Unicode character set.

Integration. Most of the programming to be done with XML involves integration, such as connecting XML to enterprise applications and creating business rules that describe the flow of XML documents. Tcl provides the most flexible and powerful facilities for integration available today. It is easy to connect Tcl to anything that needs to be integrated, and the Tcl language facilities are tailored for integration. Tcl allows integration applications to be developed 5-10x faster than other languages.

C++ and Java

So far, most commercial tools for manipulating XML have been based on system programming languages such as C++ or Java. Unfortunately, C++ and Java are a poor match to XML:

What's available today

Base-level XML support is available for Tcl programmers in the form of an open source package created by Steve Ball. The package is called TclXML; it includes a Tcl interface to James Clark's expat XML parser plus another parser written entirely in Tcl that has equivalent functionality. It is available for download at http://www.zveno.com/zm.cgi/in-tclxml.

Related information