The first chapter of the XSL Basics tutorial

Source: Internet
Author: User
Tags add format define object contains xml parser xml stylesheet xmlns
Basic Tutorials

XSL Introduction
XML Stylesheet Language XSL is much more complex than CCS.

Css:html Style Sheet language
Because HTML uses predefined tags, the meanings of these tags are well understood:<p> element defines a section of,
Using CSS to add a display format to HTML elements is a simple process: it's easy to tell the browser to display the elements in a particular font or color, and the browser is easy to understand.

Xsl:xml's style sheet
Since XML does not use predetermined tags (we can use arbitrary tags as needed), the meaning of the tag cannot be directly understood:<table> can represent an HTML table or a piece of furniture. Because of the nature of XML, browsers do not know how to display an XML document.

In order to display an XML document, you must have a mechanism to describe how to display the document. One of these mechanisms is CSS, but XSL (Extensible Stylesheet Language) is the preferred Stylesheet language for XML, which is much more complex than the CSS used by HTML.

XSL: More than just a style sheet
XSL contains 3 parts:

A method of transforming XML documents;

A method of defining XML parts and schemas;

A method of formatting an XML document.

If you don't understand this, you can first interpret XSL as a language that transforms XML into HTML, a language that filters and categorizes XML data, a language that addresses the part of an XML document, A language that can format XML data based on data values (such as displaying negative numbers in red), a language (such as a screen, paper, or sound) that outputs XML data to different devices.

XSL is a WWW standard
XSL is a standard recommended by the WWW Association. The first two parts of the language became the recommended standard for the consortium in November 1999. The full XSL recommendation Standard, which includes the XSL Format section, became a candidate for the consortium in 2000.

XSL language
XSL actually contains three languages, the most important of which is XSLT.

XSL is a combination of three languages
As mentioned above, XSL actually contains three languages, specifically:

XSLT is a language that transforms XML;

XPath is a language that defines an XML part or schema;

An XSL formatted object is a language that defines how XML is displayed.

XSLT is a language used to convert XML documents into other types of documents or other XML documents. XPath is a language that addresses the part of an XML document. Design XPath is for XSLT to use. Formatting is the process of turning the result of an XSL transformation into an output format appropriate for the reader or audience.

November 16, 1999, XSLT and XPath are published as two separate recommended standards for the consortium. There are currently no separate documents for the document for the XSL format object, but there is a description within the XSL1.0 recommendation standard.

xslt:xsl Conversion
XSLT is the most important part of the XSL standard, which is used to convert an XML document into another XML document or another type of document, that is, to convert an XML document into a format that the browser can recognize. One of these is HTML. Typically, XSLT converts each XML element into an HTML element.

XSLT can also add new elements to the output file, or remove some elements. It can rearrange these elements and classify elements, test and determine which elements to display, and so on.

A common term for describing this conversion process is that XSL converts an XML source tree into another XML result tree (or converts an XML source document into another XML result document) in XSLT.

How XSL Works
In the process of conversion, XSLT uses XPath to define the part of the source document that matches one or more predefined templates. When a match is found, the XSLT converts the matching part of the source document to the resulting document, and the part of the source document that does not match any of the templates will eventually remain unchanged in the result.

This article focuses on XSLT and XPath
Most of the chapters in this article are focused on XSLT and XPath. We will use XSLT to define the XML transformations, with XPath to define the matching pattern for the transformation. Even if the XSL contains 3 different parts of different names, we will still use the common terminology of XSL.

XSL Browser
Currently, there are very few browsers that support XSL, and we will demonstrate XSL using internet Explorer 5.0来.

XML parser for Internet Explorer
In order to process an XML document with XSL, you need an XML parser with an XSL engine. Currently, Internet Explorer 5.0 is the only browser that meets this condition. Therefore, the code in this article is only working in Internet Explorer 5.0 or later.

XSL engine for Internet explorer
The XSL in Internet Explorer 5.0 is not 100% consistent with the most recently published standard for the International Consortium XSL. Internet Explorer 5 was released before the XSL standard was completely fixed, and the XSL standard was still a working draft. But Microsoft has pledged to address this issue in the next release.

The examples in this article are very small in contrast to the formal example of the official Consortium XSL recommendation, and these examples are well suited for XSL learning.

The only visible difference in an example is the XSL Stylesheet Declaration:

This is the standard method in the recommended format for the <xsl:stylesheet xmlns:xsl=: "Http://www.w3.org/1999/XSL/Transform" >

This is the way Internet Explorer (from the XSL work draft): <xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl" >

Internet Explorer MSXML
MSXML 2.0 is the name of the XML parser carried by IE 5.0, and MSXML 2.5 is the name of the parser that Windows 2000 carries, and MSXML 3.0 is the latest version of the XML parser. MSXML3.0 can be downloaded from Microsoft and will be carried by future versions of Internet Explorer and Windows.

According to Microsoft, MSXML 3.0 is compatible with the official WWW XSL standard 100%: "MSXML 3.0 is significantly more advanced than MSXML 2.5: Secure Server HTTP access, full implementation of XSLT and XPath, To sax changes (a simple API for XML), more consistent with the standards of the consortium, and the fixes of many bugs.



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.