.NET & XML
|
| List Price: | £30.99 |
| Price: | £26.34 & eligible for FREE Super Saver Delivery on orders over £5. Details |
Availability: Usually dispatched within 24 hours
Dispatched from and sold by Amazon.co.uk
Product Description
If you're seeking ways to build network-based applications or XML-based web services, Microsoft provides most of the tools you'll need. XML is integrated into the .NET Framework and Visual Studio .NET, but if you want to get a grasp on how .NET and XML actually work together, that's a different story. With .NET & XML, you can get under the hood to see how the .NET Framework implements XML, giving you the skills to write understandable XML-based code that interoperates with code written with other tools, and even other languages. .NET & XML starts by introducing XML and the .NET Framework, and then teaches you how to read and write XML before moving on to complex methods for manipulating, navigating, transforming, and constraining it. To demonstrate the power of XML in .NET, author Niel Bornstein builds a simple hardware store inventory system throughout the book. As you move from chapter to chapter, you'll absorb increasingly complex information until you have enough knowledge to successfully program your own XML-based applications. This tutorial also contains a quick reference to the API, plus appendices present additional .N ET assemblies that you can use to work with XML, and how to work with the .NET XML configuration file format. One study puts the potential market for new software based on XML at or near $100 billion over the next five years. The .NET Framework gives you a way to become a part of it. But to use XML and .NET effectively, you need to understand how these two technologies work together. This book gives you the insight to take full advantage of the power the two provide.
Product Details
- Amazon Sales Rank: #501891 in Books
- Published on: 2003-11-24
- Original language: English
- Number of items: 1
- Binding: Paperback
- 400 pages
Editorial Reviews
About the Author
Niel M. Bornstein, with over ten years' experience in software development, has worked in diverse areas such as corporate information systems, client-server application development, and web-hosted applications. Clear and engaging, Niel is a frequent contributor to xml.com, an affiliate site of the O'Reilly Network.
Excerpted from .NET and XML by Niel M. Bornstein. Copyright © 2003. Reprinted by permission. All rights reserved.
CHAPTER 7 - Transforming XML with XSLT
You now know how to read XML from a variety of data sources and formats, write XML documents in different formats from arbitrary data structures, create and manipulate XML documents in memory using the DOM, and navigate through any XML tree using XPath. Each of these functions builds on those that came before to open up a new series of possibilities.
The next logical step is to transform the presentation of XML data from one format to another. Extensible Stylesheet Language Transformations (XSLT) is designed to do just that.
Extensible Stylesheet Language (XSL) is a language designed to provide presentation for the content of XML documents. It is composed of three parts: XSLT, Xpath (which you’re already familiar with from Chapter 6), and XSL Formatting Objects (XSL-FO).
In this chapter, I’ll show you XSLT and the .NET assembly that deals with it, System.Xml.Xsl. But first, some background.
The Standards
The terms XSL and XSLT, while similar, do not refer to the same W3C specification. XSL, the Extensible Stylesheet Language itself, is simply a language for expressing stylesheets. A stylesheet is a document that controls the presentation of an XML document of a given type. XSL can be thought of as analogous to Cascading Style Sheets (CSS); in fact, XSL shares most of its properties with CSS2, although they have different syntaxes.
XSLT, the XSL Transformation language, is a subset of XSL that was originally designed to perform transformations of XML elements into complex styles, such as nested tables and indexes. XSLT is designed to be usable independent of XSL; however, its use is constrained by its design as a transformation language for the sorts of tasks required by XSL.
Despite the differences, you’ll often see the acronyms XSL and XSLT used interchangeably. Unless the speaker is describing complete formatting systems, odds are good that XSL is probably actually a mis-cited reference to XSLT. To add to the confusion, Microsoft has chosen to call the .NET XSLT namespace System.Xml.Xsl.
XSL-FO, or XSL Formatting Objects, provides additional, more complex formatting for XML content. However, Microsoft does not implement any specific XSL-FO functionality in .NET, so it is outside the scope of this chapter. If you’re interested in learning about XSL-FO, you should look into one of the available books about it, such as XSL-FO (O’Reilly) or Definitive XSL-FO (Prentice Hall).
Introducing XSLT
A document written in XSLT, referred to as a stylesheet, describes the transformation of a particular type of XML document into another format. These other formats can include not only XML languages, such as HTML and Scalable Vector Graphics (SVG), but languages using other syntaxes, such as plain text, Comma Separated Values (CSV), and any number of others—including your choice of proprietary formats. In fact, the range of output formats is limited only by the amount of work you want to do to create the appropriate stylesheet—or to locate an appropriate stylesheet created by a third party.
XSLT can be thought of as a little language, providing complete functionality for a limited set of tasks. A little language is defined as a specialized, concise notation, designed for a specific family of problems. Much simpler than a general-purpose programming language, a little program does a limited number of things very efficiently.
Although it was designed simply to provide for the transformation of XML documents, XSLT is often used to process XML documents in other ways. XSLT can be used to generate summary statistics about XML documents, store information from an XML file in a database, or communicate data from an XML file to a mobile device. Again, the applications are limited only by your imagination.
A Brief Introduction to the XSLT Specification
The XSLT specification was designed with several goals in mind. First, the XSLT stylesheet itself is an XML document. This allows you to manipulate the stylesheet like any other XML document, up to and including transforming the stylesheet itself into another format via XSLT.
Next, the XSLT language is based on pattern matching. In fact, much of the pattern matching power of XSLT comes from the XPath specification, which is discussed in Chapter 6.
Third, like any good functional programming language, each XSLT function is free of side effects. The benefit this design goal creates is that the same function will havethe same effect on any source node on which it is invoked, no matter how many times it has already been invoked on that or any other node.
Finally, flow control in XSLT is managed through iteration and recursion. The concept of iteration will be familiar if you’ve used C#'s foreach statement. The idea is that, given a collection of nodes, the same set of functions will be applied to each one in order. Recursion should also be familiar to developers experienced with modern programming languages; a recursive function is one that calls itself during its execution.
XSLT processing consists of loading an XML source document into a source tree, applying a series of templates to the nodes in the source tree, and sending the resulting data to a result tree. Where the source document comes from, and where the result document is written to, are left up to the XSLT implementation.



