content_3110_1

Transforming XML Some talk about XML as a document format. Some talk about it as an underlying hierarchical model for storing data. At another level, an XML document can be perceived as data traveling through a network of processing agents. Each network node stores or processes the data and transmits the result to a neighbor node. In this world, an XML document is data flowing through or between applications on a network. However we look at it, any XML document is a collection of elements organized in accordance to a certain schema (whether explicit, through the use of a DTD or other schema, or implicit, without a defined schema) and is also a potential hierarchical structure. We can also say that the XML document is a serialized version of a hierarchical structure – a plain text document used for information exchange between processing agents. However, internally these processing agent do not use the serialized version (the XML document) but a more workable internal representation. If XML is to truly help us create flexible applications that will talk to each other across platforms and in different applications, and if we really want to re-use the data we mark up in XML and share that data using XML as a common format, we need to be prepared for people and applications that do not use the same structure for their data we do. In this chapter we will look at ways in which we can transform the structure of our data into another XML vocabulary, or just re- order our own data. In this chapter, we will concentrate on the transformation aspect of processing XML. There are many reasons why we need to transform XML, so we will start this chapter with a look at why and when we might want to transform XML into other forms. The majority of the chapter will use XSL transformations, although we will have a discussion at the end of the chapter about other methods for transformations.