Chapter 3 of the basic XSL tutorial

Source: Internet
Author: User
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:
    
  
    
  
    
  
    
  
    
  
      












  
      









                                                                                                           
TitleArtist

  
    
  
    
  
    
  
    
  
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:
    
  
    
  
    

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.