If the client XSL browser supports XML, you can use XSL to convert the document into HTML in the browser. A JavaScript solution previously explains how to use XSL to convert a document from XML to HTML. The trick is to add one to the XML file.
Client XSL
If the browser supports XML, you can use XSL to convert the document into HTML in the browser.
A JavaScript solution
Previously, we explained how to use XSL to convert a document from XML to HTML. The trick is to add an XSL style table to the XML file and then let the browser convert it. Even if this method works, it is not a satisfactory method to include a style sheet reference in an XML file, and this method does not work in browsers that do not support XSL.
A more common method should be to use JavaScript to convert XML to HTML. When you use JavaScript, you are more likely:
Promise JavaScript to perform browser detail test;
Apply different style sheets according to the browser and user requirements.
This is the beauty of XSL. One of the goals of the XSL design is to transform data from one pattern to another, so as to support different browsers and different user needs.
The client XSL transformation will become an important part of the future browser work task. we will also see the growth of the professional browser market, such as Braille, voice network, network printer, Handheld PC, mobile phone, etc.
XML and XSL files
Now let's take a look at the XML document in the previous chapter:
Reference content is as follows:
Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985
.
.
.
There are also accompanying XSL style sheets:
Reference content is as follows:
Make sure that the XML file does not reference the XSL file, nor does the XSL file reference the XML file. Note: The above sentence clarifies that an XML file can be converted using many different XSL files.
Convert XML to HTML in a browser
The following is the source code required to convert an XML file to HTML on the client, which is very simple:
Reference content is as follows: