Follow me to learn XSL (1) the first XML document

Source: Internet
Author: User
Tags empty xsl

With the development of the Internet, more and more information into the Internet, information exchange, retrieval, storage and reuse, such as the urgent need for HTML, the most commonly used markup language has become increasingly stretched. HTML integrates data content with performance, modifiable, poor data retrieval, and XML borrowed from the advantages of HTML and database, program language, the content and performance apart, not only make the search more convenient, more important is the exchange of data between users more convenient, reusable more strong.

XML is a Meta markup language that offers more flexibility for web developers without a number of fixed tags. When we use HTML, the markup simply represents the display of the content, without any association with the content, which is extremely inconvenient for further processing of the document. For example, to represent a personal resume, use the HTML representation as follows:

<HTML>
<BODY>
<table border=1 cellspacing=0>
<TH> name <TD> Euchierne <TH> sex <TD> man <TH> birthday <td>1977.5
<TR>
<TH> Skills <TD colspan=5> Database design and maintenance, web development
</TABLE>
</BODY>
</HTML>

Name Euchierne Gender Man Birthday 1977.5
Skills Database design and maintenance, web development

What the example looks like in the browser

Here, we can not learn from the mark Th, TD what its content, if the use of XML, the corresponding document (filename: personal resume, XML) can be written in the following form:

<?xml version= "1.0" encoding= "GB2312"?>
<resume>
<name> Euchierne </name>
<sex> male </sex>
<birthday>1977.5</birthday>
<skill> database design and maintenance, Web development </skill>
</resume>


What the previous example looks like in a browser (IE5.0 or later)

Description

version── stipulates the version of the XML document, which can only be 1.0;

encoding── here, the encoding type of the XML document is specified, where the value is "GB2312", which is "Simplified Chinese".

Comparing two examples, using XML we can do custom tags, with tags to indicate the meaning of the content. This provides great convenience for using computers to process documents when exchanging data on the Internet, and we don't get confused by a lot of formatting when we read the source files.

However, since XML does not show the way for tagging, if we look at the above two documents in the viewer (we recommend using IE5.0 or newer versions), we will see that the XML document is not displayed in the form of a table. Can't we just display the document like HTML? The answer is in the negative. Take your resume as an example, you need to create a separate format file that describes how each tag is displayed, as follows (assuming the file name is Resume.css):

resume{Display:block;}
name{display:block; font-size:120%;}
sex{display:block; Text-indent:2em}
birthday{display:block; Text-indent:2em}
skill{display:block; Text-indent:2em}

Description

All of the above are CSS style, we recommend that readers refer to the relevant information familiar with CSS, in the future learning must be used, here due to the length of the relationship is not introduced. After creating the file Resume.css, add the following text after the first line of the resume. xml file:

<?xml-stylesheet type= "Text/css" href= "Resume.css"?>


What the previous example looks like in a browser (IE5.0 or later)

Description

An external CSS style file is referenced here, where type stipulates the style type (preferably text/css or text/xsl), and the href prescribes the file path.

Save the file, and then open the file in IE5.0. What do you think? The format is somewhat different. As if not satisfactory, the document content is clear, but the display effect than the HTML written document is much worse, the XML written documents can only be shown in this way?!

Tips:

1. For better understanding and mastery of XML, it is recommended that you familiarize yourself with HTML 4.0 and CSS 2.0 syntax; master JavaScript, at least one in VBScript; programming experience, knowledge of database theory and SQL can benefit everyone in learning XML.

2. The tags in the XML document must appear in pairs, if the empty tag must have a tag with the same name as "/", or use this type <xml_mark/> to represent the empty tag.

3. XML and the XSL document to be described below, attribute values must be enclosed in double quotes (") or single quotes (').

4. XML documents must be well-formed (XSL documents are also one of the XML documents), that is, tags must have closing tags, tags can be nested but not intersect, such as:

<outer><inner></inner><inner/></outer>

is legal, and the following form

<outer><inner></outer></inner>

Is wrong. If an XML document fails while browsing, it is mostly a violation of the rules mentioned above.

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.