By Les Hamilton
Editor’s note: This article originally appeared in TechRepublic’s Web Development Zone TechMail. Subscribe, and you’ll receive information on Web-development-related projects and trends.
With the great many advantages that we get from using Extensible Markup Language (XML) as a data storage and exchange protocol, we still cannot implement it to directly display content on the Web. For development purposes, however, Microsoft has provided us with a way to format and display our XML-based information with Internet Explorer 5 (and later). IE 5 in hand, let us examine how to process XML data for the Web.
Unlike Hypertext Markup Language (HTML), XML provides no formatting information. To display XML information on the Web, we must use Extensible Stylesheet Language (XSL) or Cascading Style Sheets (CSS). XSL is a data-driven means of modifying an XML document. Unlike CSS, which matches HTML tags to presentation attributes, XSL provides the ability to transform and stylize an XML document. With XSL, you can suppress content or sort the information being presented. XSL uses pattern matching to apply formatting to the different elements of an XML document.
First in a series
This article from TechRepublic’s Web Development Zone describes ways to format XML and XSL. Future articles will discuss XML and ASP integration, and combining XML, ActiveX Data Objects (ADO), and ASP.
XSL is a derivative of XML that uses templates to configure the information from the XML into a format resembling a standard HTML document. To produce the user output, the process requires two documents—one XML and one XSL. When the two documents are combined in the browser, you can see the results by using the View Source command. XSL manipulates the information via a set of elements and methods invoked using the XSL namespace. With XSL, we have the ability to process our data with looping constructs, as shown in this example:
Given the XML layout, this code could be used for displaying a quick list of fellow employees on your intranet:
<?xml:stylesheet type="text/xsl" href="demo.xsl"?>
If you’re looking for an XML and XSL development tool, XML Spy is the first true integrated development environment (IDE) for XML that includes all major aspects of XML in one powerful and easy-to-use product:
- XML editing and validation
- Schema/DTD editing and validation
- XSL editing and transformation
XML Spy is a professional validating XML editor for Windows developers, IT professionals, and Web design people that lets you edit all XML, XML Schema (XSD), XHTML, XSL, Resource Description Framework (RDF), Wireless Markup Language (WML), and document type definition (DTD) files. XML Spy provides five advanced views on your documents: an Enhanced Grid view for structured editing, a Database/Table view that shows repeated elements in a tabular fashion, a Text view with syntax coloring for low-level work, a graphical XML Schema Design view, and an integrated Browser view that supports both CSS and XSL style sheets.
For a more detailed description of the features available in XML Spy 3.5, please visit the company’s Web site.