xsl-list
[Top] [All Lists]

Re: apply template

2004-08-24 07:00:59
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/



<Prev in Thread] Current Thread [Next in Thread>