Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Matching values of nodes to apply templates [Thread Next] Re: Matching values of nodes to apply templatesTo: NULL Date: 10/5/2004 1:09:00 AM roac@p... (Joris Gillis) wrote in message news:<a402073b.0410041020.6befbf45@p...>...
> > I am wishing to apply a template to the following XML. There are
> > multiple event nodes within the register root node. For each of the
> > event nodes there are a list of students taking the Event. I wish to
> > apply a template (and thus get the data) for the same student across
> > the events. I can apply the template to student 18 for event 1, how
> > do i then get the data for student 18 from event 2 and then for event
> > 3 and so on?
>
> Hi,
>
> I think this might be a way to the solution of your problem.
>
> <xsl:key name="students" match="student/code" use="."/>
>
> <xsl:template match="/">
> <xsl:apply-templates select="//student[generate-id(code) =
> generate-id(key('students',code))]">
> <xsl:sort select="name"/>
> </xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match="student">
> student name: <xsl:value-of select="name"/>
> <xsl:apply-templates select="//event[student/code=current()/code]"/>
> </xsl:template>
>
> <xsl:template match="event">
> event: <xsl:value-of select="code"/>
> </xsl:template>
>
> this code produces:
>
> student name: Janet Bloggs
> event: 1
> event: 2
> student name: Joe Bloggs
> event: 1
> event: 2
>
> Is this useful?
>
>
> Joris Gillis
Many thanks to both of you for your help - I believe that this will work.
David
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
