The Extensible Stylesheet Language (XSL), a family of transformation languages, allows one to describe how to format or transform files encoded in the XML standard. The language assumes the processing of an input XML file to produce a text-based output document, generally HTML, XML, plain-text, or PDF.
On top of the usual frustrations with poor, incomplete, and incorrect implementation of standards and typically buggy and poorly-supported programs, add my frustration with trying to integrate these tools with other similarly joyful tools and you can see that my job is a recipe for bitterness and pain.
This article explains the basics of XSL to transform XML documents using simple examples. We will gradually focus on using ASP.NET to implement XSLT for any XML document and even to database queries. It introduces different ways of implementing XSL from browser's perspective and server's perspective. We will also discuss some tips to generate automated XML from database queries and then transform them to HTML using XSL transformations.
The two most well-known XSLT processors are probably the Apache project's Xalan (available in both a Java and C++ version) and the Java-based Saxon, which was written by XSLT 2.0 specification editor Michael Kay. If those are the only two XSLT processors you currently use, it's worth checking out Daniel Veillard's libxslt.
Many have wished for a tool that would automate the creation of XSLT stylesheets. Building the interface alone to such a tool sounds like a tough job, and getting it to output working XSLT stylesheets that accomplish non-trivial tasks also sounds challenging. However, the comfort level of nearly all computer users with basic spreadsheet software actually makes the first task simpler than it once appeared to be, and the ease with which popular spreadsheet programs now save their contents in XML means that when you start with the right spreadsheet template, an XSLT stylesheet is not difficult to create from the XML version of a spreadsheet that uses that template.
Since the early days of XSLT, many have asked whether it was possible to automate the creation of XSLT stylesheets. The general idea of filling out a form or dragging some icons around, then clicking a button and seeing a productive stylesheet generated from your input has always appealed to people. However, the problem of generating working XSLT syntax from the result of someone clicking on pull-down menus and radio buttons has not attracted many takers.
As XML formatted content and data becomes pervasive on intranets and the Internet the requirement to minimize individual process times becomes great. XPath has been evolving into a rich expression language to query and extract data in a precise way. While it has been designed to be used by a host language such as XSLT and XQuery, an XPath processor can be used quite usefully standalone or as part of an application framework.
This chapter will take you a few steps further by showing you how to add text and markup to your result tree with XSLT templates. First, you'll addliteral text to your output. Then you'll work with literal result elements, that is, elements that are represented literally in templates. You'll also learn how to add content with the text, element, attribute, attribute-set, comment, and processing-instruction elements. In addition, you'll get your first encounter with attribute value templates, which provide a way to define templates inside attribute values.
XML considers four characters to be whitespace: the carriage return, the linefeed, the tab, and the spacebar space. Microsoft operating systems put both a carriage return and a linefeed at the end of each line of a text file, and people usually refer to the combination as the "carriage return". XSLT stylesheet developers often get frustrated over the whitespace that shows up in their result documents -- sometimes there's more than they wanted, sometimes there's less, and sometimes it's in the wrong place. Over the next few columns, we'll discuss how XML and XSLT treat whitespace to gain a better understanding of what can happen, and we'll look at some techniques for controlling how an XSLT processor adds whitespace to the result document.
This article deals with the display of tree-structures that are driven by a database. There are actually a few approaches to transform a 2-dimensional structure into a tree, and it seems odd that most are unknown to many developers.
DocBook is a collection of standards and tools for technical publishing. DocBook was originally created by a consortium of software companies as a standard for computer documentation. But the basic 'book' features of DocBook can be used for other kinds of content, so it has been adapted to many purposes.
XML Schema documents are deﬁned using an XML syntax, which means that the idea of generating schema documentation through standard XML technologies is intriguing. We present X2Doc, a framework for generating schema-documentation solely through XSLT. The framework uses SCX, an XML syntax for XML Schema components, as intermediate format and produces XML-based output formats. Using a modular set of XSLT stylesheets, X2Doc is highly conﬁgurable and carefully crafted towards extensibility. This proves especially useful for composite schemas, where additional schema information like Schematron rules are embedded into XML Schemas.
XPath 2.0 is the foundation of two essential recommendations currently in the final stages of development at W3C: XSLT 2.0 and XQuery. It is a major rewrite designed to significantly increase the power and efficiency of the language. In this article, BenoÃ®t Marchal shows how the new data model enables you to easily write more sophisticated requests.
If you need to learn XSL, or think it might be a career-enhancing move, there are currently very few books that describe XSL. In fact, some of these books can be overwhelming in size and in programming detail. The XSL Companion is different, and, I feel, aptly named a 'companion'.
XML feeds, though useful, are boring to look at in a browser because they are simple XML files. It's possible though to make them easier on the eye, and in this article we'll look at two ways of doing that. First, we'll use simple CSS properties to format each XML node, and then we'll use a little more complex but much more powerful XSL transformation.
BMC Software Inc., a company that writes utility tools for database administrators, wanted to reuse the error messages from partner database companies. Having learned that two of these database companies already used single-source files for their error messages, BMC Software integrated the information about the error messages from the database companies. We accomplished our goal by negotiating with our partner companies for the source files of the error message information. This session discusses how we took those source files and modified them to create simple XML files, then transformed them into HTML using XSL transforms within a product.
To meet the needs of users worldwide, today's Web applications often require internationalization. In this article, you'll see an approach for client-side internationalization based on XSLT. This solution only requires that both the data to be internationalized and the server stores are in XML.
XML is a data format concerned primarily with compatibility and flexibility. But as useful as XML is, it's limited without the abilities to find specific portions of a document quickly and to filter and selectively locate data within a document. XPath provides the ability to easily reference specific text, elements, and attributes within a document—and with a fairly low learning curve. Additionally, XPath is key to many other XML vocabularies and technologies, such as XSL and XQuery. This tutorial will teach you the fundamentals of XPath, including all of its various selectors and semantics, in an example-driven and hands-on manner.
This month I'm taking a break from covering XSLT 2.0 to describe how the combination of XSLT 1.0 and an application with an open XML format solved a problem for me. I solved this problem so quickly and easily that it got me thinking about how the combination of XSLT 1.0 and the increasing amount of open XML formats are opening up a world of simple, valuable new applications and utilities for us to write.
Covers XPath's new ability to do some things that every real programming language can do: conditional statements and iteration, or, as they're more colloquially known, "if" statements and "for" loops. We'll also look at a useful related technique for checking whether certain conditions do or don't exist in a set of nodes.