I think they are different. xsl:for-each will loop on the nodes in the list "select"ed. Any course of action for the list of nodes can be mentioned within the scope of xsl:for-each, as shown below -
<xsl:for-each select="//chapter">
<!-- call template matching rule for node -->
<xsl:apply-templates select="."/>
</xsl:for-each>
OR
<xsl:for-each select="//chapter">
<!-- print the nodename -->
<xsl:value-of select="name()"/>
</xsl:for-each>
WHEREAS
<xsl:apply-templates select="//chapter">
will go through each element in the node list and apply the template matching rule. Hence <xsl:for-each> can simulate <xsl:apply-templates> and much more. Hope that i'm clear on this part.
Coming to the xslt processor stuff, i'm using the
java processor classes from the Apache's xalan xslt website here -
http://xml.apache.org/xalan-j/ You will be applying the stylesheets to the xml files from the command line.
The following are the sequence of steps i followed to get the stuff working on my m/c -
1) download xalan-j_2_4_0-bin.zip from the above site
2) extract the zip file in any of the directories
3) You then need to go to the xalan/bin directory and extract the contents of some of the jar files here as "jar -xvf xalan.jar", then the same thing for xercesImpl.jar and xml-apis.jar. This process will basically extract all the class files which will be used by the our xslt processor.
4) The most important thing then is to update the CLASSPATH variable on our m/c with the absolute path of our xalan/bin directory.
5) To ensure that everything is properly set up on ur m/c, you need to run the following command from the command line -
java org.apache.xalan.xslt.Process
and it should give you a list of options as shown below -
=================================================
-IN inputXMLURL
-XSL XSLTransformationURL
-OUT outputFileName
-V (Version info)
-QC (Quiet
Pattern Conflicts Warnings)
-TT (Trace the templates as they are being called)
-TG (Trace each result tree generation event)
-TS (Trace each selection event)
-TTC (Trace the template children as they are being processed)
-EDUMP [optional]FileName (Do stackdump on error)
-XML (Use XML formatter and add XML header)
-TEXT (Use simple Text formatter)
-HTML (Use HTML formatter)
-PARAM name value (Set a stylesheet parameter)
-DIAG (Print number of milliseconds transform operation took)
-FLAVOR flavorName (Transform with SAX for s2s or DOM for d2d)
-URIRESOLVER fullClassName (Use a custom URIResolver)
-ENTITYRESOLVER fullClassName (Use a custom EntityResolver)
-CONTENTHANDLER fullClassName (Use a custom ContentHandler)
-INCREMENTAL (Request incremental transform by setting
http://xml.apache.org/xalan/features/incremental to true)
-NOOPTIMIZE (Request no optizimation of stylesheet processing
by setting
http://xml.apache.org/xalan/features/optimize to
false)
-RL recursionLimit (Set numeric limit on depht of stylesheet
recursion)
-L (Turn on source_location attribute)
================================================
This make sure that you are all set to go. If you didnot set the classpath stuff properly, you will get the no class defintion found error.
6) Next thing is that you need to write a sample test.xml file (say) and write some xsl file for that (test.xsl) and run the command as follows -
java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl -out test.txt
You can find all these details at the website mentioned above. Please come back if you face any problems doing this and please correct me for any mistakes.
Thanks.