[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 6 Oct 2006 23:31:29 +0100
RE:  with-param looping problem...
> My stylesheet looks like this:

Without trying to understand or solve your problem in detail, there are some
real oddities in your code.

>       <xsl:key name="task" match="Task" use="UID"/>

>                   <xsl:for-each select="//Task">

Here you're selecting all the tasks in the document.

>                       <xsl:for-each select="key('task',UID)">

Here you're selecting each task whose UID is the same as that of the current
task. But since the UIDs of the tasks seem to be unique, it seems this will
always select the current task, in other words it's the same as
<xsl:for-each select=".">, which is a no-op.

>                           <tr>
>                               <td>
>                                   <xsl:value-of select="key 
> ('task',UID)/Name"/>

Now you're selecting the current task yet again, and outputting its Name. I
don't know what you're trying to do here, but it really looks as if you've
misunderstood what key() does. In each of these expressions,
key('task',UID)/UID can simply be replaced by UID.

>      <xsl:template name="get-uid">
>          <xsl:param name="rid"/>
>          <xsl:call-template name="get-name">
>              <xsl:with-param name="rid"/>
>          </xsl:call-template>
>       </xsl:template>

This template doesn't appear to add value. What's the point of a named
template that just calls another named template with the same parameter?
Calling get-uid has exactly the same effect as calling get-name.

Except - I just noticed this - it isn't passing on the value of its
parameter. That would be <xsl:with-param name="rid" select="$rid"/>
>       <xsl:template name="get-name">
>           <xsl:param name="rid"/>
>       <xsl:value-of select="key('worker',UID)/Name"/>
>       </xsl:template>

This named template is fishy because it doesn't use the value of its
parameter $rid. Perhaps you meant <xsl:value-of
select="key('worker',$rid/UID)/Name"/>. Except that you're calling the
template without supplying a value for the parameter, so it makes some kind
of perverse sense to not use the value that you aren't supplying. But I'm
left totally confused as to what you're actually trying to achieve.

The key named "worker" only makes sense if you supply it a UID that
identifies a resource. But you're supplying UID, which is the UID child of
the context node, which is still a <Task>, because you haven't done anything
that changes the context.

Michael Kay

Current Thread


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.
First Name
Last Name
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-2013 All Rights Reserved.