[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

grouping node-sets in an external document

Subject: grouping node-sets in an external document
From: Carl Yu <carl.yu@xxxxxxxxxxxx>
Date: Fri, 10 Jan 2003 13:57:34 -0800 (PST)
 grouping node-sets in an external document
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>
</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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.