[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: Multiple Views.


Subject: Re: Multiple Views.
From: Gilbert Roulot <issarlk@xxxxxxxxxx>
Date: Tue, 26 Jan 1999 15:21:45 +0000

Jason Diamond wrote:
> 
> 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.

[cut]

> 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?

I don't believe you can do that with XSL, but I know you can do it with
LotusXSL (bug ?) using an "Attribute Value Templates" (things that are
inside {} ) in a select. Look at this code :

xml file :

<data>
 <projects>
   <project>
     <name>Project X</name>
     <employeeref ref="A"/>
     <employeeref ref="B"/>
   </project>
   <project>
     <name>Project Y</name>
     <employeeref ref="B"/>
   </project>
   <project>
     <name>Project Z</name>
     <employeeref ref="B"/>
     <employeeref ref="C"/>
   </project>
 </projects>

 <!-- datas on employees separated, -->
 <!-- this solve the multiple appearance of an employee -->

 <employees>
  <employee id="A">
   <name>Alice</name>
  </employee>
  <employee id="B">
   <name>Bob</name>
  </employee>
  <employee id="C">
   <name>Carol</name>
  </employee>
 </employees>
</data>

xsl file :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="employees">
 <html><head><title><xsl:text>Employee's
project</xsl:text></title></head><body>
 <xsl:for-each select="employee">
  <b>
   <xsl:value-of select="name"/><xsl:text>' Projects</xsl:text>
  </b><ul>
  <!-- look for projects that have this employee in them -->
  <xsl:for-each select="//projects/project/employeeref[@ref='{@id}']">
    <li><xsl:value-of select="../name"/></li>
  </xsl:for-each>
  </ul>
 </xsl:for-each>
 </body></html>
</xsl:template>

</xsl:stylesheet>

it produces an html with a list of each employee's projects.
It doesn't work with Xt, this is not legal to use attribute value
template like that. And probably this very useful bug will be corrected
in futur LotusXSL version.

I think what you (and I) need is XQL a query language that looks a lot
like XSL, but I don't know if there are implementation of it yet.(are
there ?) 


For outputing to different files, there's a way to do it with Xt
(filters written in java) but it's not standard to XSL.

-- 
Gilbert Roulot


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



Current Thread
  • Multiple Views.
    • Jason Diamond - Tue, 26 Jan 1999 01:24:01 -0800
      • Gilbert Roulot - Tue, 26 Jan 1999 15:21:45 +0000 <=
      • <Possible follow-ups>
      • keshlam - Wed, 27 Jan 1999 09:28:03 -0500
Keywords