[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: with-param looping problem...

Subject: Re: with-param looping problem...
From: "James A. Robinson" <jim.robinson@xxxxxxxxxxxx>
Date: Sun, 08 Oct 2006 08:57:10 -0700
Re:  with-param looping problem...
> 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)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.