What is XSL and what is its purpose

Source: Internet
Author: User
Tags add format contains end version xsl xsl stylesheet xslt

XSL is to XML like CSS to HTML. It refers to the Extensible Stylesheet Language (extensible Stylesheet Language). This is a language for rendering XML data in a readable format. XSL actually contains two parts:

* xslt– the language used to convert XML documents

* xpath– language for navigating in XML documents

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

XSLT can convert an XML document into another XML document, XHTML output, or simple text. This is usually done by converting each XML element to an HTML element. Because XML tags are user-defined, browsers do not know how to interpret or render each label, so you must use XSL. The meaning of XML tags is for the convenience of the user (not the computer) to understand.

XSLT can also perform the following actions on an XML tree:

* Add and remove elements

* Add and Remove properties

* Rearrange or sort the elements

* Hide or show some elements

* Find or select specific elements

XSL syntax

As you may recall, the XML overview article mentions that all XML documents begin with an XML declaration. The same is true for XSL stylesheets. The first line of any XSL document is actually an XML declaration:

<?xml version= "1.0" encoding= "Iso-8859-1"?>

is XSL the same as XML?

Both and not. Yes, because they follow the same grammatical rules (only a little bit of difference, as I'll say below). No, because they are different: XML is used to host data, and XSL is used to format the data.

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

<xsl:stylesheet>

Or

<xsl:transform>

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

<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" version= "1.0" >

This is because, according to the consortium's recommendations, it also contains versions of namespaces and XSL specifications.

The difference between an XSL declaration and an XML declaration is that the XML declaration writes only one line and there is no end tag, and the XSL declaration must contain an end tag that represents the end of the XSL stylesheet:

</xsl:stylesheet>

Note that this does not conflict with the XML syntax rule: The XSL stylesheet is a fully valid XML document because it has a root element that is specified by the label.

Under what circumstances should XSL be used?

XSL has several goals for design purposes, which make it a perfect solution for some development scenarios and useless for other development scenarios.

XSL is designed to work with XML documents and follows XML syntax. Therefore, it can only be used in conjunction with XML in XML-enabled applications. The most appropriate use of XML and XSL is a web portal, news aggregator, community web site, or any other Web application that needs to provide information to a variety of devices and to a large number of clients.

XSLT is a language that is based on pattern matching. It looks for nodes that match specific criteria, and then applies the appropriate rules. Therefore, it does not have the computational power of most programming languages. For example, XSL cannot change the value of a variable at run time. It should not be used to calculate values from dynamic data sources, such as online stores, that use complex formulas. The Web programming language is better suited for this purpose.

XSL cannot replace or supplement CSS. It should not (and cannot) be used to set the style of HTML. However, you can use it for Web sites that require frequent redesign of visualizations, frequent replacement layouts, and processing of data in a flexible format.

XSL is not a content management tool. It should not (and cannot) be used to change the contents of an XML document or to edit information. However, you can use XML and XSL for content management systems that need to handle several different formats of documents.



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.