What is xsl xslt XPath?

Source: Internet
Author: User
Tags xsl xslt
XSL

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 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

XSL 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"?>

Is XSL 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.

Under what circumstances should I use XSL?

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.

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.