Subject: Re: with-param looping problem...
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Sun, 08 Oct 2006 08:57:10 -0700
|
> Basically, I'm trying to group the task with the job and the resource
> assigned to the task. The task UID seems to provide the common
> element to group them all together. For example, the Task/UID is
> referenced in the Assignemnt node as the TaskUID, which also includes
> the ResourceUID. I'm trying to use the //Assignment/ResourceUID to
> locate the //Resource/UID and retrieve the //Resource/Name.
So you want to process the Assignment elements, emitting a table
which lists the Assignment UID, the Task Name, and the Resource
Name?
I'd start with a simple approach first, and move on to keys and
such only if you find the simple approach isn't fast enough. This
is one way you could do what you want, I think:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:apply-templates select="/Project/Assignments"/>
</xsl:template>
<xsl:template match="Assignments">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="Assignments/Assignment">
<tr>
<xsl:apply-templates select="TaskUID"/>
<xsl:apply-templates select="UID"/>
<xsl:apply-templates select="ResourceUID"/>
</tr>
</xsl:template>
<xsl:template match="Assignment/UID">
<td><xsl:value-of select="string(.)"/></td>
</xsl:template>
<xsl:template match="Assignment/TaskUID">
<td><xsl:value-of select="/Project/Tasks/Task[UID = string(current())]/Name"/></td>
</xsl:template>
<xsl:template match="Assignment/ResourceUID">
<td><xsl:value-of select="/Project/Resources/Resource[UID = string(current())]/Name"/></td>
</xsl:template>
</xsl:stylesheet>
It produces:
<table>
<tr><td>Do something</td><td>1</td><td>Tom</td></tr>
<tr><td>Do something else</td><td>2</td><td>Dick</td></tr>
<tr><td>Do everything else</td><td>3</td><td>Harry</td></tr>
<tr><td>A job</td><td>4</td><td>Tom</td></tr>
<tr><td>A biggger job</td><td>5</td><td>Dick</td></tr>
<tr><td>the biggest job</td><td>6</td><td>Harry</td></tr>
</table>
Is that the kind of grouping you are after?
Jim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
|