Say I have XMLise the book The Complete Reference – Java. Now instead of writing the contents of the book, I (rather everybody) would like to generate it from the tags. So..
Following is the XML structure –
<Books>
<Book>
<Part n="1" h="The Java Language">
<SubHead h="Basics">
<Topic n="1" h="The History and Evolution of Java">
.....
</Topic>
<Topic n="2" h="An overview of Java">
.....
</Topic>
<Topic n="3" h="Data Types, Variables, and Arrays">
.....
</Topic>
</SubHead>
<SubHead h="Intermediate">
<Topic n="4" h="Operators">
.....
</Topic>
<Topic n="5" h="Control Statements">
.....
</Topic>
<Topic n="6" h="Looping">
.....
</Topic>
</SubHead>
</Part>
<Part n="2" h="OOPS">
<SubHead h="Basics">
<Topic n="7" h="Introduction to Classes">
.....
</Topic>
<Topic n="8" h="Inheritance">
.....
</Topic>
</SubHead>
<SubHead h="Intermediate">
<Topic n="8" h="Packages and Interfaces">
.....
</Topic>
<Topic n="9" h="Exception Handling">
.....
</Topic>
</SubHead>
</Part>
</Book>
</Books>
The dotted lines means the content of the book. Now How to get the following output in HTML, along with the detailed description of the contents of the Topic Tag. I mean to say that, I am looking for the Content section of any book.
Part 1 - The Java Language
Basics
1. The History and Evolution of Java
2. An overview of Java
3. Data Types, Variable, and Arrays
Intermediate
4. Operators
5. Control Statements
6. Looping
Part 2 - OOPS
Basics
7. Introduction to Classes
8. Inheritance
Intermediate
9. Packages and Interfaces
10. Exception Handling
Following Xsl gives you an output data you’re asking:
The output will be: