xsl-list
[Top] [All Lists]

Re: [xsl] test for child element

2006-12-20 09:32:15
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 

m> --~------------------------------------------------------------------
m> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
m> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
m> or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
m> --~--


-- 
Alexey                            mailto:nikolaenkov(_at_)actimind(_dot_)com


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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