Hi Kevin,
The only distinct/grouping I can see if the values of @presence?
Try something like...
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:key name="kDistinctPresence" match="element.for.housework.def"
use="@presence"/>
<xsl:template match="/">
<html>
<body>
<xsl:variable name="chefs"
select="/housework.definition/sequence.def.list/sequence.def/sequence.def.ro
le"/>
<table border="1">
<!-- do the chef header row -->
<tr>
<th/>
<xsl:for-each select="$chefs">
<th>
<xsl:value-of select="@role"/>
</th>
</xsl:for-each>
</tr>
<!-- now do the rows for each distinct @presence -->
<xsl:apply-templates
select="/housework.definition/element.for.housework.def.list/element.for.hou
sework.def[generate-id() =
generate-id(key('kDistinctPresence',@presence))]">
<xsl:with-param name="chefs" select="$chefs"/>
</xsl:apply-templates>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="element.for.housework.def">
<xsl:param name="chefs"/>
<xsl:variable name="this-presence"
select="key('kDistinctPresence',@presence)/@element.name"/>
<tr>
<th align="right">
<xsl:value-of select="@presence"/>
<xsl:text>:</xsl:text>
</th>
<!-- now do columns for each chef with this @presence value -->
<xsl:for-each select="$chefs">
<td>
<!-- look for matches withing this chef of the current @presence -->
<xsl:for-each select="element.for.sequence.def.role/@element[. =
$this-presence]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:for-each>
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Kevin Brown" <kb1381@gmail.com> wrote in message
news:555d5de3.0408251855.34f75fc4@posting.google.c om...[color=blue]
> Is there anyway to generate this type of resulting HTML table from
> this XML using XSLT? Basically I need to be able to consult 2 trees of
> data to generate the HTML, but I have not been able to figure out how
> to do so. There is supposed to be a way of using templates and the key
> function to do grouping, but can it be done with 2 different trees? If
> so, are there any examples of such things
>
> Thanks for any help,
>
> Kevin
>
> ***
>
> HTML Table
>
> chef 1 chef 2 chef 3
> must: make.pizza
> pour.milk
> maybe: make.orange.juice make.ice.cream make.martini
> never: make.apple.pie
>
>
> ***
>
> XML File
> <?xml version="1.0" encoding="LATIN1" standalone="yes" ?>
> <!--
> <!DOCTYPE housework.definition PUBLIC "house work xml"
> "housework.dtd">
>
> -->
> <housework.definition housework.name="kitchen work"
> docclass.name="house work">
> <element.for.housework.def.list>
> <element.for.housework.def element.name="make.pizza" presence="must"
> />
> <element.for.housework.def element.name="pour.milk" presence="must"
> />
> <element.for.housework.def element.name="make.orange.juice"
> presence="maybe" />
> <element.for.housework.def element.name="make.apple.pie"
> presence="never" />
> <element.for.housework.def element.name="make.ice.cream"
> presence="maybe" />
> <element.for.housework.def element.name="make.martini"
> presence="maybe" />
> </element.for.housework.def.list>
> <sequence.def.list>
> <sequence.def sequence="stage 1">
> <sequence.def.role role="chef 1">
> <element.for.sequence.def.role element="make.pizza" />
> <element.for.sequence.def.role element="pour.milk" />
> <element.for.sequence.def.role element="make.orange.juice" />
> </sequence.def.role>
> <sequence.def.role role="chef 2">
> <element.for.sequence.def.role element="make.apple.pie" />
> <element.for.sequence.def.role element="make.ice.cream" />
> </sequence.def.role>
> <sequence.def.role role="chef 3">
> <element.for.sequence.def.role element="make.martini" />
> </sequence.def.role>
> </sequence.def>
> </sequence.def.list>
> </housework.definition>[/color]