XSL increment variables solve the problem of family trees

xiaoxiao2021-03-06  68

XML has no increment variables Once a variable is defined, he cannot change this equivalent to the final field in Java, but in some cases, the recursive method of combining templates can be achieved.

As a result, if the XML file is Familytree.xml each XML in this XML Element can contain any number of child elements, which is called family, and should be appropriate to indent the text according to the family system when showing this family tree.

This is to give a visual representation, for example, Otto Sandra Lichao ZHANGSAN ERIC HALI LISI HELI ANDY to write XSLT style sheet FamilyTree.xslt

XMLns: XSL = "http://www.w3.org/1999/xsl/transform"> < - select the top level person ->

SELECT = "'0'" /> < XSL: Template Match = "Person">

And usually the same style table begins with the root node of the text, and enter a basic

HTML document, then it selects the root element to pass the level = 0 as a parameter to match Person

Template: and Person Template uses an HTML DIV Display everyone's name and EM in a new line

Set the indentation of the text. Finally recursive calls the Person template, transfer $ level 1 as a parameter,

Tube does not increase an existing variable but he does deliver a new local variable to template.

in. The value of this variable is greater than the previous value, which is different from the skill of recursive processing, in practice in XSLT.

Method without incremental variable

转载请注明原文地址:https://www.9cbs.com/read-86567.html

New Post(0)