Re: [xsl] with-param looping problem...

Subject: Re: [xsl] 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

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=""; version="2.0">
  <xsl:template match="/">
    <xsl:apply-templates select="/Project/Assignments"/>
  <xsl:template match="Assignments">
  <xsl:template match="Assignments/Assignment">
      <xsl:apply-templates select="TaskUID"/>
      <xsl:apply-templates select="UID"/>
      <xsl:apply-templates select="ResourceUID"/>
  <xsl:template match="Assignment/UID">
    <td><xsl:value-of select="string(.)"/></td>
  <xsl:template match="Assignment/TaskUID">
    <td><xsl:value-of select="/Project/Tasks/Task[UID = string(current())]/Name"/></td>
  <xsl:template match="Assignment/ResourceUID">
    <td><xsl:value-of select="/Project/Resources/Resource[UID = string(current())]/Name"/></td>


It produces:

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

Is that the kind of grouping you are after?


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)

Current Thread