[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: apply template

Subject: Re: apply template
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 24 Aug 2004 15:00:59 +0100
blog xsl template
Hi Jan,

> 	<xsl:template match="/">
> 		<div class="Blog">
> 			<xsl:for-each select="myns:Blog/myns:Entry">
> 				<xsl:apply-templates/>
> 			</xsl:for-each>
> 		</div>
> 	</xsl:template>

When you have <xsl:apply-templates> with no select attribute it's the
same as having:

  <xsl:apply-templates select="child::node()" />

So you are iterating over each of the <Entry> elements with the
<xsl:for-each> and applying templates to their *children*, skipping
the other template in your stylesheet. You don't have a template for
any of the elements that are children of the <Entry> elements, so the
built-in templates are used. The built-in templates essentially give
you the string value of the elements that you apply templates to, so
you get the string value of all the children of the <Entry> elements.

What you wanted to do was apply templates to the <Entry> elements, so
do:

<xsl:template match="/">
  <div class="Blog">
    <xsl:apply-templates select="myns:Blog/myns:Entry" />
  </div>
</xsl:template>

or:

<xsl:template match="myns:Blog">
  <div class="Blog">
    <xsl:apply-templates select="myns:Entry" />
  </div>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.