Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Matching values of nodes to apply templates

From: dhepworth@-------.--- (----- --------)
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent