Can XSLT do everything CSS can do?

I do not know XSLT. I just wondered and had a very simple question.

Like CSS for HTML and XSLT for XML.

Does this mean that XSLT allows developers to create advanced CSS elements such as position, float, wrap, border-collapse, opacity, etc.

+6
source share
6 answers

XSLT is not like CSS.

CSS details how this markup is displayed on this medium (on screen, on paper, on speakers, etc.).

XSLT turns one XML document into another document (XML, HTML, or plain text, most often XML or HTML).

XSL more generally began with more CSS-like goals to describe in detail how an XML document should be presented. This project has grown into several different projects with XSL-FO serving this role, and XSLT does the transformations mentioned above. It was originally designed to help with XSL-FO (XSLT would turn some XML into XSL-FO, which would detail rendering), but now has many uses outside of it, so it makes sense to separate it.

CSS can be used directly in XML, so the closest thing to CSS in the XML world is CSS.

+7
source

You confuse XSLT with XSL-FO. The latter, yes, was once designed to style arbitrary XML documents. The idea was as follows:

any XML -> XSL-FO document -> print / PDF / whatever ^ | XSLT stylesheet 

The name "stylesheet" in XSLT has nothing to do with the term "stylesheet" in CSS.

XSL-FO and CSS were developed side-by-side for some time when the CSS working group decided to break with XSL-FO people around 2006.

XSLT itself is best viewed as a programming language for converting one XML format to another or any other text format. It gives nothing to visual styles.

+3
source

XSL-FO (not XSLT) is XML that CSS is for HTML. And yes, assuming you have a good XSL-FO processor, you can create complex formatting.

http://en.wikipedia.org/wiki/XSL_Formatting_Objects

+2
source

"Like CSS for HTML, and XSLT for XML."

Not really: XSLT converts XML to completely different documents or even to formats where CSS simply describes the browser as an HTML document style.

You can even use XSLT to generate HTML in CSS if you really wanted to!

+2
source

No, XSLT will convert your XML to HTML, and then CSS will still do β€œthings like position, float, wrap, crash collapse, opacity, etc.” The browser does not understand XSLT.

+1
source

An XSLT file is a transformation template used to represent XML using HTML. You can embed inline CSS in your HTML or specify a CSS file that will be used to create your HTML code, but XSLT will not modify the original XML file.

+1
source

Source: https://habr.com/ru/post/902763/


All Articles