Introduction to XML, XSL, XSLT, and xpath

Source: Internet
Author: User
Tags xslt

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

You may remember the XML OverviewArticleAs mentioned in, all XML documents begin with 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 in applications that support XMLProgramAnd XML. The most suitable scenarios for using XML and XSL are: web portals, news aggregators,CommunityWebsites or any other web application that needs 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 a majorityProgramming LanguageComputing power. 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.

In the HTML element

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.

Element defines the table-and the browser knows how to display it.

XSLT is a language used to convert XML documents into XHTML documents or other XML documents.

XPath is a language used for navigation in XML documents.

What is XSLT?

XSLT refers to XSL Transformation (XSL transformations ).

XSLT is the most important part of XSL.

XSLT can convert an XML document into another XML document.

XSLT uses XPath for navigation in XML documents.

XPath is a W3C standard.

XSLT = XSL Conversion

XSLT is the most important part of XSL.

XSLT is used to convert an XML document to another XML document, or other types of documents that can be recognized by the browser, such as HTML and XHTML. Generally, XSLT converts Each XML element into an (x) HTML element to complete this task.

With XSLT, you can add or remove elements and attributes to or from an output file. You can also rearrange elements, perform tests, and decide which elements to hide or display.

A common saying about the conversion process is,XSLT converts an XML source tree to an XML result tree.

XSLT uses xpath

XSLT uses XPath to search for information in XML documents. XPath is used to navigate the XML document through elements and attributes.

How does it work?

During the conversion process, XSLT uses XPath to define the parts of the source document that can match one or more predefined templates. Once the matching is found, XSLT converts the matching part of the source document to the result document.

XSLT is W3C Standard

XSLT was established as W3C standard in November 16, 1999.

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.