xsl templates

when we use multiple xsl templates and apply them

<xsl:template match="/">
                        <h1>order info:</h1>

what are the practical use cases and sample examples on using multiple xsl templates say converting one xml to other xml format or from xml to html

please advise
Who is Participating?
Geert BormansConnect With a Mentor Information ArchitectCommented:
In my opinion the XSLT Cookbook is only useful really if you happen to need one of the recipes in it. I have it in my bookcase and I rarely ever open it.... but it is OK to have a different opinion of course (de gustibus et coloribus ....)
I do agree that Doug Tidwells XSLT is an excellent resource, mainly because it starts explaining XSLT starting from the concept of multiple templates. It is a very good learning resource (many other XSLT books are good references, this one is an excellent learning book to read from cover to cover)
Understanding the template vs. apply-templates mechanism is crucial to get started. Many developers new to the language approach the language from a procedural point of view. And they get stuck when they have one single template with a whole lot of sl:for each statements nested

My take on this
- XSLTs rule based nature allows to have tiny pieces of operational code inside a single template, triggered by a particular rule
- setting up the many templates in a logical fashion keeps code very maintainable
- being descriptive in the matching rule and allowing the data to flow through the apply-template and template mechanism leads to code that works with little effort
- the mechanism allows for rules that work in different contexts (one single rule takes care of all emphasis elements, regardless of where they are in mixed content, be it titles, body or table cells)

Once you have removed the last for-each from your code in favor of apply-templates, you will understand the beauty of the design
BigRatConnect With a Mentor Commented:
The best advice I can give you, without writing yards of text, is to buy Sal Mangano's book "XSLT Cookbook" O'Reilly ISBN 0-596-00974-7 which contains lots of real life examples. And if you haven't got it, the XSLT book by Doug Tidwell, also O'Reilly ISBN 0-896-52721-1 which I have found to be an extremely useful reference book which also contains practical examples.
In my opinion the XSLT Cookbook is only useful really if you happen to need one of the recipes in it

Yes, Geert, but when you are just starting out and learning, you get a lot of "how to do it properly" examples.
Geert BormansInformation ArchitectCommented:
Let's not confuse gudii9 more on this little detail in the question and agree we have a different opinion
(in my XSLT network there are quite a few that share your opinion,
so if it works for those who like the book, even better.)

Crucial for gudii9 is getting started with a proper understanding of the apply-templates mechanism.
The Doug Tidwell book is an excellent way to get started because it does exactly that (if possible try to get the old XSLT1 edition because that really sets the scenery straigth from teh start, the XSLT2 edition is somewhat more cluttered)
Here you can view the book, though I am not sure it is a legal reference, please check first

I use the second edition (https://www.amazon.com/XSLT-Mastering-Transformations-Doug-Tidwell-ebook/dp/B0043D2DVO) in my XSLT classes, but students tend to complain that it is too much... it is somewhat harder to get the balance right when writing down all the details on XSLT2
Geert BormansInformation ArchitectCommented:
the accepted answer does a summary of the usefulness of the approach
the assisted answer does good book references to learn about the approach
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.