XSL is for XML, just like CSS for HTML. EXtensibleStylesheetLanguage ). This is a language used to display XML data in a readable format. XSL actually contains two parts: * the language in which XSLT is used to convert XML documents
XSL is for XML, just like CSS for HTML. It refers to EXtensible Stylesheet Language ). This is a language used to display 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 describe or describe each label, so XSL must be applied. The significance of XML labels is to help users (rather than computers) understand.
XSLT can also hold the XML tree as follows:
* 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:
Is XSL similar to XML?
Neither. Yes, it is because they follow the same syntax rules (only a little difference, I will talk about it below ). No, because they are used differently: XML is used to carry data, while XSL is used to set the data pattern.
After the XML declaration, it is the XSL declaration, for example:
Or
However, in most cases, the XSL declaration looks a little more complex:
This is because, according to the W3C Alliance's recommendations, 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 without the end tag, and the XSL declaration must contain the end tag, which indicates that the XSL style table ends:
Note that this does not conflict with XML syntax rules: The XSL style sheet is a complete and valid XML document because it has a root element specified by the tag.
Under what circumstances should XSL be applied?
XSL has several goals for use in design, which make it a perfect solution in some development situations, while it is useless in other development situations.
XSL is used to process XML documents and comply with the XML syntax. Therefore, it can only be used with XML in the exploitation program supporting XML. The most suitable scenarios for XML and XSL applications are Web portals, message aggregators, community websites, 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 uses the corresponding rules. Therefore, it does not have the computing power of most programming languages. For example, XSL cannot change the volume value at runtime. It should not be used to calculate values from dynamic data sources that apply 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 high frequency, new design visualization, frequent layout changes, and mobile data processing.
XSL is not a content governance tool. It should not (or cannot) be used to modify the content of an XML document or compile information. However, you can use XML and XSL for content governance systems that need to process documents in several different formats.