Re: [xsl] Beginner XSL question

Subject: Re: [xsl] Beginner XSL question
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 16 May 2002 13:50:23 -0600 (MDT)
Arturo C wrote:
> Hi and sorry my english... how can i count the number of elements, for 
> instance, student in the following case:
> <school>
>    <student>
>       ....
>    </student>
>    <student>
>       ....
>    </student>
>    <student>
>       ....
>    </student>
> </school>
> and show the result (3) in an HTML page using XSL?

To get you started, and to demonstrate several principles, here is an example.
It assumes each <student> contains a <name>. You should get a good book on
XSLT. Try these:

   - Mike
  mike j. brown                   |  xml/xslt:
  denver/boulder, colorado, usa   |  resume:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"

  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">

  <xsl:template match="school">
    <p>There are <xsl:value-of select="count(student)"/> students.</p>
      <xsl:apply-templates select="student"/>

  <xsl:template match="student">
      <xsl:value-of select="concat('Student #',position(),' of ',last(),': ',name)"/>


 XSL-List info and archive:

Current Thread