The previous period we talked about the use of CSS (laminated style sheets) to format XML documents, and its effect is not very satisfactory. In fact, CSS is used to format HTML tags, just because it is simply used in the previous example. XML is just a data file in more, how to change it to the files like the HTML format we have seen in our daily? If we compare the XML file than the structured raw material, then XSL is better than "sieve" and "mold", and the sieve is selected from the raw materials you need, and these raw materials form the final product: HTML. This mold is roughly like this: We first design the page of the performance, and then get the data in the XML to fill the contents "digging", and then use the XSL statement from the related data from the XML to populate. One words: this XSL is actually a "shell" of HTML, XML data utilizes this "shell" to generate "traditional" HTML. XML is a tree structure when the XML is expanded. We refer to a custom tag in the tree structure as a node, and there is a father and son between the nodes. Layer enters. In the case of XSL, we have to be from the raw library? ? The relevant data is extracted in XML, and the mode query language provided by XSL is used. The so-called moderative query language is the specific statement of data from the XML through the related mode matching rule expressions, namely what we say "Sieve". Refer to Microsoft's "XSL Developer Guide", we can roughly divide the pattern language into three: select mode , , and test mode XSL: IF> and Matching Matches We now introduce them. First, select the mode selection mode statement to extract the data from the XML, is a simple acquisition of data, these tags have a select property, select the data of a specific node name in XML. 1, such as this in XML: Xiao Yu name> Chunhua Name> Qiushi Name> Author> We want to read these three author names, is it one by one to read the "Author / Name" method, have multiple such names? If there is a procedural statement to loop how good! I think that XSL provides such a programming language-based statement to read these three author names: ... <./xsl: 201ach> SELECT, As the name refer: Choose, it can select a specific unique tag in XML, or select a certain tag, we call it a set. Syntax: Properties: 1. SELECT query the context according to the XSL style query to determine which type of node set (satisfying SELECT condition) Style description. As a simplified representation, if you want to format the display method of a tag in the document, you can let the SELECT equal to the marked name of this element.
For example, if you want to format the marker XML_mark, you can use it as follows: xsl: for-each> 2. Order-by Segmentation (;) separated as a list of sorting standards. Adding a plus number ( ) before the list element indicates that the contents of this tag are sorted as ascending order, and the reduction ration (-) represents the reverse sequence. As a simplified representation, the sort standard list is the sequence of the marker specified by SELECT, and each tag is separated between (;). 2, mode is just selecting the node, and does not remove the value of the node. It is like the monkey just climbed to a branch of the tree, then use Let's pick "Victory Fruit"! Syntax: Value attributes for extracting nodes: select uses the XSL model that matches the current context.
Simply put, if you want to insert an XML tag somewhere in the XSL document (assuming is the XML_Mark tag), you can use it as follows: xsl: value-of> Or example: As an example of a personal resume in the previous period, we need to make certain modifications to the file (personal resume .xml), exactly the first Two lines Xml: stylesheet type = "text / css" href = "resume.css"?> Modified to Xml: stylesheet type = "text / xsl" href = "resume.xsl"?> Then establish a new File: Resume.xsl, its contents are as follows: XML Version = "1.0" encoding = "GB2312"?> < HEAD> Personal resume title> head>
Personal resume caption>
Name th>
< / TD>
Gender TH>
td>
birthday th>
td> tr>
Skill th>
td> < / TR> table> xsl: for-energy> body> html> Complete these will let us look at the achievements of hard work, how? Good effect. More cool is still behind.