XSL concise tutorial (4) implementation on the server

Source: Internet
Author: User
Original article: JanEgilRefsnes translation: Ajie 4: XSL --- implement it on the server 1. compatible with all browsers in the previous chapter, we first introduced the ability to use JavaScript to call the XMLparser (parsing software) of the browser to convert XML documents. But this plan is based on

Original: Jan Egil Refsnes
IV. XSL --- implementation on the server

1. compatible with all browsers

In the previous chapter, we first introduced how to use JavaScript to call the XML parser (parsing software) of the browser to convert XML documents. However, this plan still has a title: if the browser does not have XML
What should I do with the parser plug-in? (Note: XML parser is included in IE5)

In order to make our XML data accurately displayed by all browsers, we have to convert XML into pure HTML code on the server side and then output it to the browser.

This is another benefit of using XSL. Converting one pattern into another pattern on the server side is also one of the design objectives of XSL.

Similarly, conversion will become an important task for future server segments.

2. a specific instance

The following is part of the code in the above-mentioned XML document (cd_catalog.xml) example:




Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985
...

The complete XSL file (cd_catalog.xsl) is as follows ):

















Title Artist




The following is the original code for converting an XML file to an HTML file on the server:

<%
'Load the XML
Set xml = Server. CreateObject ("Microsoft. XMLDOM ")
Xml. async = false
Xml. load (Server. MapPath ("cd_catalog.xml "))
'Load the XSL
Set xsl = Server. CreateObject ("Microsoft. XMLDOM ")
Xsl. async = false
Xsl. load (Server. MapPath ("cd_catalog.xsl "))
Response. Write (xml. transformNode (xsl ))
%>

Note: The example here uses an ASP file written in VBScript. If you do not know ASP or VBScript, you are advised to browse related books. (Of course, you can also write server programs in other languages)

The first code creates an object parsed by Microsoft Parser (XMLDOM) and reads the XML file into the memory. The second code creates another object and imports it into the XSL document; the last line of code converts the XML document into an XSL document and outputs the result to an HTML file.


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.