File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes what is template rule in xsl ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "what is template rule in xsl ?" Watch "what is template rule in xsl ?" New topic

what is template rule in xsl ?

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 374
Following example is taken from the link ""

xml file that contains content

xsl file used to transform xml in html

What does <xsl:apply-templates/> do ?
I was reading this example online and it was sated that
<xsl:apply-templates/> means: "go and look for other rules"
what does this mean ? where does the control go, when it encounters
<xsl:apply-templates/> as there is no other rule for root element "page" ?

in this example, we have "title" as a child element of "page" element. To access "title", do we need to have template for root elelment , <xsl:template match="page"> ? Can we access "title" without template for "page" like as follows by placing forward slash before "title" ?

I have read in other book that <xsl:apply-templates> is used when there unstructured content and tags in that unstructured cntent is t be matched. e.g. there are some <bold> texts in a paragraph and we can apply <B> for all the occurrences of <bold> using <xsl:apply-templates/> this secod use makes more sense to me. So does i mean that <xsl:apply-templates> can be used for both purposes ? Are these two purposes same or different ? Please explain if there is something wrong in understanding.

Please explain the use of <xsl:apply-templates> as its very confusing and has already taken lot of my time

I agree. Here's the link:
subject: what is template rule in xsl ?