|
Article Excerpt The power and elegance of XSLT -- the Extensible Stylesheet Language for Transformations -- stems from its ability to transform XML documents into other output formats like HTML, fulfilling one of the original promises of XML: separating content from presentation.
XSLT is particularly powerful because a single stylesheet can format all the XML documents conforming to a DTD into HTML for publication on a Web site. The stylesheet can also be used to automatically generate such features as a hyperlinked table of contents, the building of which requires substantial manual work without XML.
XSLT is also elegant, because if you need to reformat all the pages in your Web site, for instance, you need to change the code in only one place, the stylesheet, so long as your source documents are in XML.
Written primarily for content authors, technical writers, Web designers, and other nonprogrammers, this tutorial aims to demonstrate some of XSLT's power and elegance in separating content from presentation and in automatically generating narrative-oriented HTML documents while showing you how to create progressively more complex template rules -- rules that are at the core of XSLT.
Review: The Template Rule
In its most basic form an XSLT stylesheet uses what are called template rules to match nodes in an XML document and transform them into another format. A template rule is an XSL element that matches a node in the XML source document and typically applies an output format, such as HTML, to it. For example, say you have the following simple XML document:
You've probably heard the propaganda by now: XML blesses you with a way to separate content from presentation.
You can use a template rule to find the children of the root element and to format its contents in HTML for presentation. Here's a template rule that does just that:
In this rule the element uses the value of its match attribute to find a node in the XML source. The forward slash operator, an XPath expression, specifies the document's root node. The rule could also match on the same node by specifying it explicitly in the template rule, that is, . By matching on the root node of the document, we're able to build an HTML container that provides the skeleton code (here, just and...
|
|

More articles from XML Journal
What's online: www.sys-con.com/xml., March 01, 2002 New series of e-learning courses. (XML News).(Online-learning.com), March 01, 2002 Book on Jabber protocols available. (XML News).(Brief Article), March 01, 2002 OASIS to develop spec for multilingual data exchange. (XML News).(Brie..., March 01, 2002 InfoSpace speech platform, VoiceGenie gateway to join. (XML News).(Bri..., March 01, 2002
Looking for additional articles?
Search our database of over 3 million articles.
Looking for more in-depth information on this industry?
Search our complete database of Industry & Market reports by text, subject, publication
name or publication date.
About Goliath
Whether you're looking for sales prospects, competitive information, company
analysis or best practices in managing your organization,
Goliath can help you meet your business needs.
Our extensive business information databases empower business
professionals with both the breadth and depth of credible,
authoritative information they need to support their business
goals. Whether it be strategic planning, sales prospecting,
company research or defining management best practices -
Goliath is your leading source for accurate information.
|
|