Re: [xsl] test for child element

Subject: Re: [xsl] test for child element
From: Alexey Nickolaenkov <nikolaenkov@xxxxxxxxxxxx>
Date: Wed, 20 Dec 2006 19:31:35 +0300
Wednesday, December 20, 2006, 7:22:22 PM, you wrote:

m> <root>

m>   <level1>
m>         <note><para>First note</para></note>
m>          <note><para>Second note</para></note>
m>          <note><para>third note</para></note>
m>      <text>Some text</text>

m>   </level1>

m> Under <level1> template I am checking to see if the
m> first child element is a "note" and then displaying
m> it.
m>
m> How do I check to see if the following elements are
m> also "note" elements?
m> If they are then I want them to
m> be displayed int he following format:

m> First note
m> Second note
m> Third note

IMO you shouldn't check if there are any other note elemets if you
want to produce the output above you have only to  apply templates
to the note element.

Try something like that

<xsl:template match="level1">
   <xsl:apply-templates select="note"/>
   .. do something else
</xsl:template>


<xsl:template match="note">
   <xsl:apply-templates select="para"/>
</xsl:template>

<xsl:template match="para">
   <xsl:value-of select="."/>
</xsl:template>

m> How do I make it
m> check if there are any more notes after the first
m> note?

following-sibling::note



m> __________________________________________________
m> Do You Yahoo!?
m> Tired of spam?  Yahoo! Mail has the best spam protection around 
m> http://mail.yahoo.com 


-- 
Alexey                            mailto:nikolaenkov@xxxxxxxxxxxx

Current Thread