Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: newbie question on apply-templates

From: "Yan Leshinsky" <yanl@------.---------.--->
To: 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
>> >
>> >
>>
>>
>
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent