Easy Introduction to XSLT Chapter One: The concept of XSLT _xml/rss

Source: Internet
Author: User
Tags xpath xsl xslt

1.XSLT Concept

1.1 What is XSLT
1.2 Why use XSLT
1.3 XSLT's history
1.4 What is XPath
1.5 xslt and CSS comparison
1.6 xslt and IE5 br>
1.XSLT Concept

Let's first clarify a concept, you may have heard of the XSL (extensible Stylesheet Language), the XSL and the XSLT we are talking about in the narrow sense is the same, According to the standards of the consortium, XSLT is more restrictive, so we use the XSLT notation uniformly in the article. The specific relationship between them will be described below.

1.1 What is the English standard name for XSLT

XSLT is extensible Stylesheet Language transformation. According to the specifications of the HTTP://WWW.W3.ORG/TR/XSLT, the first design XSLT was designed to help convert XML documents (document) to other documents. But as development goes, XSLT is not just for converting XML to HTML or other text formats, but a more comprehensive definition should be:

XSLT is a language used to transform the structure of XML documents.

1.2 Why use XSLT

We already know that XML is a simple and standard way of exchanging raw data between computer programs. Its success does not lie in its easy to be written and read by people, and more importantly, it fundamentally solves the information exchange between application systems. Because XML meets two basic requirements:

(1). Separate the data from the presentation. Like the weather information can be displayed on different devices, TV, cell phone or other.

(2). Transfer data between different applications. The growing demand for E-commerce data exchange has made this increasingly urgent.

to make the data easy for people to read, we need to display or print the information, such as turning the data into an HTML file, a PDF file, or even a sound; In order for the data to fit into different applications, We must have the ability to convert one data format to another, such as the requirement format may be a text file, an SQL statement, an HTTP message, a certain sequence of data calls, and so on. And XSLT is the language we use to implement this conversion function. converting XML to HTML is the main function of XSLT at the moment.

The history of 1.3 XSLT

Like many other XML family members, XSLT was drafted and developed by the consortium. Its main development process is as follows:

.1995 proposed by James Clark;

. The August 1997 official proposal was XSL;

. A demand summary was completed by Norman Walsh in May 1998;

. August 18, 1998 the release of the XSL draft;

. November 16, 1999 the official release of the XSL 1.0 recommended version.

Currently, XSLT is still evolving rapidly, and XSLT1.1 's draft is already visible on the Web site (http://www.w3.org/TR/xslt11).

1.4 What is XPath

XPath is an important part of XSLT, and we will explain its detailed syntax in the fourth chapter. So what is XPath? Let's first take a look at the "family" relationships in the XSL series. The following figure:



XSL divides the XML document into two distinct processes, the first to transform the document structure, and then the document to format the output. These two steps can be separated and handled separately, so the XSL gradually splits into XSLT (structural transformation) and XSL-FO (Formatting objects) (formatted output) in two branch languages, where XSL-FO functions like CSS in HTML. And what we're talking about here is the first step of the transformation process, which is XSLT.

In addition, when learning XML, we already know that XML is a complete tree structure document. To find and locate information in an XML document, you may need to work with some of these (node) data when converting an XML document, and XPath is a language specifically used to look up information in an XML document. XPath is subordinate to XSLT, so we usually mix XSLT syntax with XPath syntax.

A better understanding of the explanation is that if you think of an XML document as a database, XPath is the SQL query language; If you think of XML documents as DOS directory structures, XPath is a collection of directory operations commands such as Cd,dir.

1.5 XSLT and CSS comparisons

CSS can also format XML documents, so why do you need XSLT when you have CSS? Because CSS is a good way to control the output of the style, such as color, font, size, etc., but it has serious limitations, is:

(1) CSS cannot reorder elements in a document;

(2) CSS can not judge and control which element is displayed, which is not displayed;

(3) CSS can not be statistical calculation of the data elements;

In other words, CSS is only suitable for the output of a more fixed final document. The advantages of CSS are simplicity, consuming less system resources; While XSLT is powerful, it consumes more memory because it is indexed to the XML tree.

Therefore, we often combine them, such as using XSLT to process documents on the server side, and using CSS to control the display at the client. can reduce response time.

1.6 XSLT and IE5

Shortly after the release of the XSLT draft, Microsoft provided a preview version of the XSL feature in IE4 to support XSLT when IE5.0 was released, but because IE5 was released earlier than the XSLT1.0 standard Time, IE5.0 features and XSLT supported in Xstl 1.0 slightly different. (hehe ~~xml Implementation of one of the main reasons is to solve the problem of HTML over-reliance on browsers, and now Microsoft wants to be unconventional? )。 Fortunately, the standards implemented in Microsoft's IE5.5 have been basically similar to the XSLT1.0 of the consortium. But the headache is that IE5.0 has released millions of sets, and the XSLT you use may well not be properly executed by the client's browser. XSLT 1.1 is still evolving, and the consortium and its organizations are also negotiating with Microsoft to achieve unification. Oh ~ ~ The story is far from over.

Note: The syntax mentioned in this article is based on the XSLT 1.0 standard and does not have any "dialect" from Microsoft.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.