[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|