XSL refers to the Extensible Stylesheet Language)

Source: Internet
Author: User
Tags xsl xslt
XSL

XSL refers to the Extensible Stylesheet Language. It is a language used to present XML data in readable format.

Directory

Introduction
Syntax
Whether XSL is the same as XML
Purpose
Application

Introduction

XSL is for XML, just like CSS for HTML. It refers to the Extensible Stylesheet Language ). This is a language used to present XML data in a readable format.

XSL is a markup language that represents how to replace the content of an XML document with another form of document.

Write XSL for XML to display XML in different formats

XSL actually contains two parts:

* XSLT-language used to convert XML documents

* XPath-language used for navigation in XML documents

XSLT refers to XSL Transformation (XSL transformation), which is the most important part of XSL.

XSLT can convert XML documents into other XML documents, XHTML output, or simple text. This is usually done by converting each XML element into an HTML element. Because XML labels are user-defined, browsers do not know how to interpret or present each label, so XSL must be used. The meaning of XML tags is to make it easier for users (not computers) to understand.

XSLT can also perform the following operations on the XML tree:

* Add and delete Elements

* Add and delete attributes

* Rearrange or sort Elements

* Hide or display certain elements

* Find or select a specific element


Syntax

As mentioned in the XML overview article, all XML documents begin with an XML declaration. The same is true for XSL style sheets. The first line of any XSL document is actually an XML declaration:

<? XML version = "1.0" encoding = "ISO-8859-1"?>


Whether XSL is the same as XML

Neither. Yes, because they follow the same syntax rules (only a little difference, I will talk about it below ). No, because they have different purposes: XML is used to carry data, while XSL is used to set the data format.

After the XML declaration, it is the XSL declaration, for example:

<XSL: stylesheet>

Or

<XSL: Transform>

However, in most cases, the XSL declaration looks a little more complex:

<XSL: stylesheet xmlns: XSL = "http: // www W3 ORG/1999/XSL/transform" version = "1.0">

This is because, as recommended by the W3C alliance, it also contains the namespace and the version of the XSL specification.

The difference between the XSL Declaration and the XML Declaration is that the XML declaration only writes one row, and there is no end tag. The XSL declaration must contain the end tag, which indicates the end of the XSL style table:

</XSL: stylesheet>

Note that this does not conflict with XML syntax rules: an XSL style sheet is a fully valid XML document because it has a root element specified by the <XSL: stylesheet> label.


Purpose

XSL has several objective purposes in design, which make it a perfect solution in some development scenarios, while it is useless in other development scenarios.

XSL is used to process XML documents and follows the XML syntax. Therefore, it can only be used with XML in an application that supports XML. XML and XSL are the most suitable scenarios: web portals, news aggregators, community websites, or any other Web applications that need to provide information to various devices and a large number of clients.

XSLT is a language based on pattern matching. It searches for nodes that match specific conditions and then applies the corresponding rules. Therefore, it does not have the computing power of most programming languages. For example, XSL cannot change the variable value at runtime. It should not be used to calculate values from dynamic data sources that use complex formulas (such as online stores. WEB programming languages are more suitable for this purpose.

XSL cannot replace or supplement CSS. It should not (or cannot) be used to set HTML styles. However, you can use it for websites that require frequent re-design of visualization effects, frequent layout changes, and flexible data processing.

XSL is not a content management tool. It should not (or cannot) be used to modify the content or edit information of an XML document. However, you can use XML and XSL to manage the content of documents in different formats.

It starts with XSL and ends with XSLT, XPath, and XSL-fo.

Started with XSL

XSL refers to the Extensible Stylesheet Language ).

The reason why the World Wide Web Consortium (W3C) began to develop XSL is that there is a need for XML-based style sheet languages.

CSS = html style sheet

HTML uses predefined tags, so the meaning of tags is easy to understand.

The element in the HTML element defines the table-and the browser knows how to display it.

It is easy to add styles to HTML elements. With CSS, it is easy to tell the browser to display an element with a specific font or color.

XSL = XML style sheet

XML does not use pre-defined labels (we can use any tag names we like), and the meaning of these labels is not so easy to understand.

Elements mean an HTML table, a piece of furniture, or something else-the browser does not know how to display it.

XSL describes how to display XML documents!

XSL-not just the style sheet language

XSL consists of three parts:

XSLT

A language used to convert XML documents.

Xpath

A language used for navigation in XML documents.

XSL-FO

A language used to format XML documents.


Application

In the field of database technology, specifically, it is a method for fast execution of extensible style form language conversion (XSLT. This method constructs a conversion tree to structure the structure information of the XML document and the XSLT conversion requirements, and then creates a stream processing model from the conversion tree. It scans the XML source document and uses the stream processing model, converts An XSLT Conversion Program into multiple event processors, which correspond to each type of events triggered during scanning, A corresponding event output segment is added to the generated results document. After scanning, the final complete results document is obtained. The method completely avoids the disadvantages that the existing conversion engine needs to load the entire source file into memory in advance, reduces memory consumption, and greatly improves the execution efficiency. Even for very large XML data, the conversion process can be completed through a scan.

1. A method to quickly execute XSLT conversion. Its feature is that XSLT conversion is performed using a stream processing model. The specific steps are as follows: (1) first, the conversion tree is constructed, combine the structure information of the XML source document with the XSLT conversion requirements. The step is to construct the DTD tree T defined by the XML document type. Evaluate the r of each conversion rule of the XSLT Conversion Program L, find the matching node n of R in T. Continue to test the O of each element in the R output template sequence. If O is a constant string, create a leaf node N for tree T ', add an edge from N to n. If O is calling the template command, find the selected node n of O from tree T, and add an edge from N to n; (2) create a stream processing model from the conversion tree. It is a recursive process. The steps include N, end (N), start (n) on any node of the conversion tree) the initial value is an empty string. If n is a leaf node, end (n): = pcdata + end (n); C1, C2 ,..., CP indicates all the child nodes under Node N from the DTD tree ,..., DQ indicates that all nodes under Node N are from XS It is the child node of the Conversion Program. If d1 is a constant string node, start (n): = start (n) + D1 and set counter I to 2. Otherwise, set counter I to 1. When I is not greater than Q, repeat the following steps: assume C is the child node of N from node n to node di, if the edge from N to C is not marked by an asterisk and di + 1 is a constant string node, end (c): = end (c) + DI + 1 and I: = I + 2; otherwise, I: = I + 1; if di + 1 is a constant string node, assume that C' is the child node of N located on the path from node n to node di + 2, then start (C'): = di + 1 + start (C ′) and I: = I + 2, otherwise make I: = I + 1; for each child node DJ, recursively call the above process; (3) scan the XLM source document, A stream processing model is used to convert an XSLT Conversion Program into multiple event processors. When reading XML from start to end to retrieve the source document, many events are triggered for each type of events, each has a corresponding output segment. At the beginning, the result document is empty. When the source document is scanned, the output part of the corresponding event is gradually added to the end of the generated result document. After the scanning process ends, the user can get the final complete result document immediately. In the final result document, end (n) is the output segment of the element end event, and start (n) is the output segment of the element start event, pcdata is the pcdata value of the current leaf node.[1]

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.