XML Programming  «Prev  Next»

Lesson 7 Using XML
Objective Describe approaches to using XML.

Approaches to Using XML

XML promotes easy data exchange. Because XML documents are text-based, they can be created, manipulated, stored, and transmitted without concern for proprietary data formats - one of the central problems that historically hindered data exchange between applications. XML documents can be distributed and displayed on the web, consumed by backend services, and processed by virtually any platform or programming language. The elimination of proprietary format lock-in is not a minor convenience: it is the property that made XML the foundation for enterprise data interchange across the industry.

XML and Pervasive Computing

XML documents contain data inside custom tags that describe the data rather than its presentation. Once an XML document is created, the same document can be shared, rendered, and consumed by multiple devices simultaneously. A single XML document on a server can be transformed into an HTML page for a desktop browser, a simplified layout for a mobile device, a formatted report for a tablet, or a structured data feed for a backend service - all from the same source document, without modifying the XML itself.

This capability is what makes pervasive computing possible: the principle that the same information can reach any device in an appropriate format. XSLT (eXtensible Stylesheet Language Transformations) is the technology most commonly used to perform these transformations, converting XML into HTML, PDF, or any other target format as needed. The XML document acts as the single source of truth; the presentation layer adapts to each device and context.

Diagram showing an XML document in the cloud exchanging data with mobile devices,
web browsers, tablets, and a backend server via bidirectional connections.
An XML document in the cloud exchanges data bidirectionally with mobile devices, web browsers, tablets, and a backend server - illustrating the pervasive computing model enabled by XML.

Seven Approaches to Using XML

XML is flexible enough to serve as the foundation for a wide range of architectural approaches. The following seven approaches represent the primary ways XML is used in practice:

  1. Document-centric. This approach represents data in a way that is primarily intended for human readers. XML documents store and transmit content in a format that is both human-readable and machine-readable, making it suitable for technical documentation, legal documents, publishing workflows, and any context where the narrative content is as important as the structure. A book published in XML format, for example, uses element names that reflect the document's structure: chapters, sections, paragraphs, and footnotes.
  2. Data-centric. This approach represents data primarily for machine consumption. XML documents store structured data in a format that software applications can parse and process efficiently. Database exports, API responses, configuration files, and financial transaction records are typical data-centric uses. In this context, the element names reflect the data model rather than a narrative structure: records, fields, keys, and values.
  3. Hybrid. This approach combines document-centric and data-centric elements in the same document. XHTML documents are a classic example: they combine HTML's narrative structure with XML's well-formedness rules. Other hybrid examples include documents that contain both structured data records and narrative text - such as a report that includes both prose analysis and embedded tabular data.
  4. Service-oriented architecture (SOA). This approach uses XML as the common data format for exchanging information between different systems and applications. XML defines the structure of the data being exchanged and the rules for processing it. Enterprise service buses, message queues, and web service integrations all rely on XML in this role. The key advantage is that systems built on different platforms and in different languages can interoperate reliably because they share a common, well-defined data format.
  5. XML-based standards. Several widely adopted web service standards are built directly on XML. SOAP (Simple Object Access Protocol) defines a messaging framework for web services. WSDL (Web Services Description Language) describes the interface of a web service in XML. UDDI (Universal Description, Discovery and Integration) provides a directory of web services described in XML. These standards enabled the first generation of machine-to-machine web service integration and remain in use in many enterprise environments.
  6. XSLT. eXtensible Stylesheet Language Transformations is a language used to transform XML documents into other formats. An XSLT stylesheet defines rules for converting an XML document into HTML for browser display, PDF for printing, plain text for downstream processing, or another XML vocabulary for a different application. XSLT is the primary mechanism by which the pervasive computing model described above is implemented in practice.
  7. XML Schema. XML Schema is a language used to define the structure and constraints of XML documents. A schema specifies which elements are permitted, in what order, with what data types, and with what cardinality. This enables the creation of custom markup languages for domain-specific data that can be validated automatically. Any document that claims to conform to the schema can be tested against it before processing begins, providing a reliable contract between data producers and consumers.

XML as a Metalanguage: Vertical Domain Applications

Because XML is a metalanguage - a language for defining other languages - it has been used to create customized, extensible markup languages across virtually every vertical business domain. Rather than forcing every industry to use a generic data format, XML allows each domain to define the vocabulary that best describes its data. The following examples illustrate how this capability has been applied in finance and telecommunications:

  1. IFX - Interactive Financial Exchange: defines a common XML vocabulary for financial transactions between banks and financial service providers.
  2. BIPS - Bank Internet Payment System: provides an XML-based framework for internet payment processing between financial institutions.
  3. TIM - Telecommunications Interchange Markup: defines XML structures for exchanging telecommunications data between carriers and service providers.
  4. PDML - Product Data Markup Language: provides an XML vocabulary for describing product data in manufacturing and engineering contexts.
  5. FIX - Financial Information eXchange Protocol: defines an XML-based standard for real-time electronic communication of securities transactions.

These domain-specific XML languages share the same parser infrastructure, validation tools, and transformation engines as every other XML vocabulary. A developer who understands XML can work with any of these standards using the same skill set, the same libraries, and the same tools.

Advantages of XML

The comparison between HTML and XML illustrates the core advantage of XML's extensible approach. HTML uses a predefined tag set: a developer creating a table uses <table>, <tr>, and <td> - tags defined by the HTML specification with no room for customization. XML, by contrast, allows a developer to define a markup language for an inventory catalog using elements that reflect the domain: <book> containing <Author>, <ISBN>, and <Copyright>. The markup describes what the data is, not how it should look.

Using XML to exchange information offers three primary advantages:

  1. XML uses human language. XML documents are readable and understandable even by developers who are new to the format. Because element names are chosen by the author to reflect the domain, reading an XML document is closer to reading a structured outline than reading code. This readability is not just a convenience for beginners - it reduces the documentation burden for any team that produces or consumes XML data, and it makes debugging integration problems significantly faster.
  2. XML is platform-independent and Java-compatible. XML is a text-based standard with no platform dependencies. Any application that can process XML - regardless of the language it was written in or the operating system it runs on - can consume an XML document. Java's XML processing support is particularly strong: JAXP, DOM, SAX, StAX, and JAXB provide comprehensive tools for parsing, validating, transforming, and binding XML documents to Java objects.
  3. XML is extensible. Developers can define their own tags using the natural language of their domain, with the attributes and structure their data requires. This extensibility is the property that distinguishes XML from HTML and from fixed binary formats. As a domain evolves and its data requirements change, the XML vocabulary can be extended without breaking existing documents or tools that have not yet been updated to handle the new elements.

The next lesson concludes this module.


SEMrush Software