xml - Nested list with number labels -
I have a nested list, and so I want the label nested too.
This is my code:
& lt ;! - For the first list - & gt; & Lt; Xsl: Template Name = "List 1-Label" & gt; & Lt; Xsl: number format = "1." / & Gt; & Lt; / XSL: Templates & gt; & Lt ;! - Nestle List - & gt; & Lt; Xsl: Template name = "list-2-label" & gt; & Lt; Xsl: number format = "1.1." / & Gt; & Lt; / XSL: Templates & gt; The first number in the last template ( 1 .1.) I want to be in relation to the original item in this case; "3". Here is the XML structure:
& lt; List1 & gt; & Lt; Items & gt; Test & lt; / Item & gt; & Lt; Items & gt; Test & lt; / Item & gt; & Lt; List2 & gt; & Lt; Items & gt; Test & lt; / Item & gt; & Lt; Items & gt; Test & lt; / Item & gt; & Lt; / List2 & gt; & Lt; Items & gt; Test & lt; / Item & gt; & Lt; / List1 & gt; Here is the output:
1 Test 2. Test 2.1 Test 2.2 Test 3. Test < The desired output can be obtained (for example) the advanced properties @from and @ country
of xsl: number . Here's an example working in which you should start: & lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/" & gt; conversion; & Lt; Xsl: output indent = "yes" /> & Lt; Xsl: strip-space element = "*" /> & Lt; Xsl: template match = "list1 / item" & gt; & Lt; Xsl: number-level = "any" to "list1" count = "list1 / item" /> & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: value selection = "." / & Gt; & Lt; XSL: Text & gt; & Amp; # 10; & Lt; / XSL: text & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "list1 / list2 / object" & gt; & Lt; XSL: Text & gt; & Amp; # 09; & Lt; / XSL: text & gt; & Lt; Xsl: number-level = "any" to "list1" count = "list1 / item" /> & Lt; XSL :. Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: number level = "any" to "list2" count = "list2 / item" /> & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: value selection = "." / & Gt; & Lt; XSL: Text & gt; & Amp; # 10; & Lt; / XSL: text & gt; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;
If you want to simplify the match pattern:
& lt; Xsl: template match = "list1" & gt; & Lt; Xsl: applied-template / & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "list1 / item" & gt; & Lt; Xsl: number-level = "any" to "list1" count = "list1 / item" /> & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: value selection = "." / & Gt; & Lt; XSL: Text & gt; & Amp; # 10; & Lt; / XSL: text & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "list2 / item" & gt; & Lt; XSL: Text & gt; & Amp; # 09; & Lt; / XSL: text & gt; & Lt; Xsl: number-level = "any" to "list1" count = "list1 / item" /> & Lt; XSL :. Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: number level = "any" to "list2" count = "list2 / item" /> & Lt; XSL: Text & gt; & Lt; / XSL: text & gt; & Lt; Xsl: value selection = "." / & Gt; & Lt; XSL: Text & gt; & Amp; # 10; & Lt; / XSL: text & gt; & Lt; / XSL: Templates & gt; This latest example will drive you correctly at more nesting levels with list3 .
Comments
Post a Comment