Subject: Multiple Views. From: Jason Diamond <sendangels@xxxxxxx> Date: Tue, 26 Jan 1999 01:24:01 -0800 |
Hi. I have an interesting question. One that I hope can be solved with XSL. I want to take some XML source and generate different views on it using just XSL. For example, if I have a list of projects with each project containing employee elements noting which employees are currently working on the project, I would like to generate a list for each employee detailing what projects they are currently involved in. Here's an example XML source: <projects> <project> <name>Project X</name> <employee>Alice</employee> <employee>Bob</employee> </project> <project> <name>Project Y</name> <employee>Bob</employee> </project> <project> <name>Project Z</name> <employee>Bob</employee> <employee>Carol</employee> </project> </projects> Now I can use the following XSL document to generate an HTML report of all the projects that Bob is currently working on: <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="projects"> <html><head><title>Bob's Projects</title></head><body><ul> <xsl:for-each select="project[employee='Bob']"> <li><xsl:value-of select="name"/></li> </xsl:for-each> </ul></body></html> </xsl:template> </xsl:stylesheet> I could repeat the above by manually changing 'Bob' to 'Alice' or 'Carol' but that would get exceedingly cumbersome if there were any more employees. Imagine a large company with hundreds. So what I'd like to be able to do is get a list of employees from the projects source. Then, take each of those employees in the list and perform the above operation. I don't think this is possible with XSL, however. My first problem is how do I get a list employees where each employee is only listed once? Even if all I wanted was to generate a list of each employee's name using the above source, Bob would show up three times. Is there some sort of modifier that could be used in a select pattern like: <xsl:for-each select="unique(employee)"> I imagine the above function would only return Bob the first time he was encountered. All subsequent Bob's would be skipped. Is this an unreasonable feature to request for the final recommendation? By the way, how do you go about requesting features, anyways? My second problem: Let's say I am able to extract a list containing one element for each employee. Is there any way to iterate through this list while using each element as an argument to the above operation which might be implemented as a macro? And if I want to output the results for each employee to a seperate file? Am I asking too much? Thanks, Jason Diamond XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Searching a CSS implementation for , Didier PH Martin | Thread | Re: Multiple Views., Gilbert Roulot |
Fw: whitespace, Oren Ben-Kiki | Date | Re: XSL with IE5.0 beta, Guy_Murphy |
Month |