one document uses a para instead of a p element (the latter of which the style sheet expects), the desired style may not be applied. These are only a few scenarios that require the use of XML schema (or a schema alternative). |
There are countless other scenarios that would warrant their use. The XML Schema Working Group care- fully outlined several usage scenarios that it wanted to account for while designing XML schema. They are as follows: |
Publishing and syndication |
E-commerce transaction processing |
Supervisory control and data acquisition |
Traditional document authoring/editing governed by schema constraints |
Using schema to help query formulation and optimization |
Open and uniform transfer of data between applications, including databases |
Metadata interchange |
As defined by the XML Schema Requirements Document, the previous usage scenarios were used to help shape and develop XML schema. |
XSLT |
Extensible Stylesheet Language Transformations (XSLT) is a language used for converting XML documents from one format to another. Although it can be applied in a variety of ways, XSLT enjoys two primary uses: |
Converting XML documents into HTML documents |
Converting XML documents into other XML documents |
The first application— turning XML into HTML —is useful for building Web pages and other browser- based documents in XML. XML defines the content and structure of data, but it doesn’t define the data’s appearance. Using XSLT to generate HTML from XML is a fine way to separate content from appearance and to build generic documents that can be displayed however you want them displayed. You can also use Cascading Style Sheets (CSS) to layer appearance over XML content, but XSLT is more versatile than CSS and provides substantially more control over the output. |
Here is how the transformation works: You feed a source XML document and an XSL style sheet that describes how the document is to be transformed to an XSLT processor. The XSLT processor, in turn, gen- erates the output document using the rules in the style sheet. You see an in-depth discussion on XSLT and its usage in .NET in Chapter 7. |
As mentioned earlier in this chapter, XSLT can also be used to convert XML document formats. Suppose company Aexpects XML invoices submitted by company B to conform to a particular format (that is, fit a particular schema), but company B already has an XML invoice format and doesn’t want to change it to satisfy the whims of company A. Rather than lose company B’s business, company Acan use XSLT to convert invoices submitted by company B to company A’s format. That way, both companies are happy, and neither has to go to extraordinary lengths to work with the other. XML-to-XML XSLT conversions are the cornerstone of middleware applications such as Microsoft BizTalk Server that automate business processes by orchestrating the flow of information. |