xsl templates

when we use multiple xsl templates and apply them

<xsl:template match="/">
            <html>
                  <body>
                        <h1>order info:</h1>
                        <xsl:apply-templates></xsl:apply-templates>

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
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BigRatCommented:
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.
1
Gertone (Geert Bormans)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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BigRatCommented:
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.
1
Gertone (Geert Bormans)Information 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
https://docstore.mik.ua/orelly/xml/xslt/index.htm

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
0
Gertone (Geert Bormans)Information 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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.