XML display -XSL style sheet (below)
Beijing University of Posts and Telecommunications
XSL template
XSL describes the output format in the output template, which can be a variety of strings, tag symbols, node values, or some XSL syntax structures, such as conditional judgment, cyclic processing, and the like. In many applications, the value of the node is required in the output template. At this point, the
The first expression of the first expression is the element of the name
After determining that the template rule matches the element, the template can be activated, which is done by
Use the
xsl: template>
P> xsl: template>
xsl: stylesheet> The first template described above matches the root element of the XML document, and applies template rules for all tag as a blank paragraph, then apply template rules to Path indicator In addition to the "//" and "/" path indicators, as well as commands "*", there are several symbols to limit the matching object of the template: ● The current node indicator is "."; ● The parent node indicator is ".."; ● The attribute indicator is "@". The above "@" represents a matching of a attribute in the specified element, such as 2. Filter match In addition to the path indicator, it is possible to filter or sort the functional objects to further adjust the application effect. When filtered, it is generally based on child elements (or attributes): ● The child element exists: ie // EMPLOYEE [SALARY] exists, select all ● Child elements Value: Employee [Salary> 25000], select all ● Attribute exists: 即 Employee [@ID] exists, select ● Attribute value: 即 Employee [@ID = "1234"], select all 3. Other extension filtering Other additional features of additional features are divided into: comparison operators, Boolean operators, and collection indexes. The writing format and function of the comparison operator are as follows: Operator function $ EQ $ is equal to $ NE $ 不 $ lt $ less than $ Le $ less or equal to $ GT $ greater than $ GE $ greater than or equal to It should be noted that the operator in the table is sensitive to the case when comparing characters. If you want to ignore the different meaning of case, add the prefix letter "i" in front of each operator, such as "$ Ieq ". Boolean operator writing format and function description: Operator function $ AND $ logic $ OR $ logic or $ not $ The result of the filtration can be further filtered through a set index. For example, Employee [Salary] [2] is to select all Employee [index () $ lt $ 2] EMPLOYEE [end ()] The selection result of the first expression is the first and second sub-elements of the Order-by = "Number (Salary" /> The first example described above indicates that the letter should be arranged in order of the name, such as "Bob" should be ranked before "TOM", and the second example is sorted by the staff in accordance with the salary.