Subject: RE: [xsl] with-param looping problem... From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 6 Oct 2006 23:31:29 +0100 |
> 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 http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] with-param looping problem..., Robert Wilkins | Thread | RE: [xsl] with-param looping proble, Robert Wilkins |
[xsl] with-param looping problem..., Robert Wilkins | Date | RE: [xsl] HTML-diff, Guy |
Month |