Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: newbie question on apply-templates [Thread Next] Re: newbie question on apply-templatesTo: NULL Date: 6/1/2004 8:36:00 AM <xsl:apply-templates/> call moduses <h3>...</h3/> part of the output by going through all children of Chapter (Section element in this case) and matching it to appropriate template (<xsl:template match="Section"><h3>... in this case). I suggest XSLT Programmer's Reference 2nd Edition by Michael H. Kay - an exelent reference book on XSLT "Raymond Du" <rdrd@y...> wrote in message news:%23YWvkv5REHA.2412@T...... > Thank you for the response, however I must be too confused to understand. > I > changed the xsl file a bit. > > Now my xsl file looks like this: > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:template match="Chapter"> > <h2> > Chapter > <xsl:value-of select="@number"/>: > <xsl:value-of select="@title"/> > </h2> > <xsl:apply-templates /> > </xsl:template> > <xsl:template match="Section"> > <h3> > <xsl:value-of select="@title"/> > </h3> > </xsl:template> > </xsl:stylesheet> > > My xml file looks like: > <Chapter number="13" title="Viewing XML Data on the Web"> > <Section title="Going from XML to HTML"/> > <Section title="Serving Up Your XML Data"/> > </Chapter> > > > The result html: > <h2>Chapter 13: Viewing XML Data on the Web</h2> > <h3>Going from XML to HTML</h3> > <h3>Serving Up Your XML Data</h3> > > If I removed <xsl:apply-templates /> from xsl file, the html will be: > <h2>Chapter 13: Viewing XML Data on the Web</h2> > > So what is <xsl:apply-templates /> for on this occasion? There is only one > Chapter element in the whole xml document, it should not make any > difference > whether it tries to match the children or not. > > Thanks Again > > > "Yan Leshinsky" <yanl@o...> wrote in message > news:ehdnQe4REHA.3344@T...... >> <xsl:apply-templates/> will try to match all children of the current > element >> against templates your stylesheet defined. The reason why you don't see > any >> difference is that content of the Chapter element doesn't match any of >> the >> templates. >> >> "Raymond Du" <rdrd@y...> wrote in message >> news:OCFwmN3REHA.2936@T...... >> > Hi, >> > >> > I am new xsl, I could not understand what apply-templates do, say : >> > >> > <xsl:template match="Chapter"> >> > <h2> >> > Chapter >> > <xsl:value-of select="@number"/>: >> > <xsl:value-of select="@title"/> >> > </h2> >> > <xsl:apply-templates /> >> > </xsl:template> >> > >> > The ouput I have is exactly the same whether it has apply-templates tag > or >> > not. >> > >> > Thanks in Advance >> > >> > >> >> > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
