|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: grouping node-sets in an external document (revise
Oops made a typo, please see the following..
>Date: Fri, 10 Jan 2003 13:57:34 -0800 (PST)
>From: Carl Yu <yuc>
>Subject: grouping node-sets in an external document
>To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
>Mime-Version: 1.0
>Content-MD5: ZGylNKg54SnZJjY2KRj61Q==
>
>I'm trying to apply the Muenchian grouping method to an external document. Of
>course, this doesn't work because the document function doesn't work within
>match statements. Am I going around this the wrong way?
>
>newFirstGraders.xml
><class name="101" type="math">
> <student>Bob</student>
> <student>Joe</student>
> <student>Mary</student>
></class>
><class name="201" type="science">
> <student>Bob</student>
> <student>Joe</student>
> <student>Mary</student>
></class>
><class name="301" type="math">
> <student>John</student>
> <student>Peter</student>
></class>
>
>firstGraders.xml
><class name="101" type="math">
> <student>Fred</student>
> <student>Mark</student>
></class>
><class name="201" type="science">
> <student>Paul</student>
></class>
><class name="301" type="math">
> <student>Wendy</student>
></class>
>
>generateSchoolReport.xsl
><?xml version="1.0"?>
><xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
><xsl:output method="xml" indent="yes" />
>
><xsl:key name="newstudents" match="document('class101.xml')/class/student"
>use="../@type" />
><xsl:key name="students" match="/class/student" use="../@type" />
>
><xsl:template match="/class/student">
> <xsl:apply-templates
>select="/class/student[generate-id(.)=generate-id(key('students', ../@type))]"
>/> mode="uniqueType" />
></xsl:template>
>
><xsl:template match="/class/student" mode="uniqueType">
>Number of Math Students: <xsl:value-of select="count(key('students','math')) +
>count(key('newstudents', ../@type))" /></xsl:attribute>
This should be :
Number of <xsl:value-of select="../@type" /> students: <xsl:value-of
select="count(key('students', ../@type)) + count(key('newstudents', ../@type))"
/>
instead.
></xsl:template>
>
></xsl:transform>
>
>Is there a way to do this (while still grouping unique groups across
documents)?
> Has this already been covered. It feels familiar, but I couldn't find a
>relevant solution through searching. I know this XSL looks bad -- I'm new...
>and this XSL was extracted from a far more complex XSL algorithm. Given this
>example, I'm sure you can write a better template match that does not require
>the 'function' call trick of using a mode='uniqueType'. I'm just too lazy to
>make a better example, sorry.
>
>Carl
Carl
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








