RE: [xsl] xslt 2. index-of, nodes

Subject: RE: [xsl] xslt 2. index-of, nodes
From: David.Pawson@xxxxxxxxxxx
Date: Fri, 4 Jul 2003 10:53:03 +0100
Thanks Jeni.

> Compare this with what you have in your stylesheet:
>   <xsl:for-each-group select="rec[mu/loc]"

I need to process only rec elements with mu/loc children,
hence the match on rec?
But point taken. I guess I could mod the XML, but its working now.

[Its not a bug Mike :-)]

> So in your stylesheet, you're grouping the <rec> elements rather than
> the <loc> elements. It shouldn't be surprising that since there's only
> one <rec> element in your XML (from the looks of it), you only get one
> group!

duh! (again :-)

> Try the following instead:
>   <xsl:for-each-group select="rec/mu/loc"
>                       group-by="concat(@hl, '+', @side, '+', @loc)">
>     ...
>   </xsl:for-each-group>

That's a worker.

> The reason that concat() didn't work is that you were presumably
> doing something like:
>     concat(mu/loc/@hl, '+', mu/loc/@side, '+', mu/loc/@loc)
> In this function call, the first, third and last arguments all select
> sequences containing multiple nodes

 The concat() function expects its arguments
> to either be empty sequences ('empty node-sets' in XPath 1.0
> terminology) or singleton sequences (single values or node-sets
> containing a single node in XPath 1.0 terminology).

I was close. But missed the context difference :-)

A concat() call like the one I suggested:

  concat(@hl, '+', @side, '+', @loc)

is fine because the paths @hl, @side and @loc cannot select more than
one node because no two attributes on an element are named the same.

Very clear now thanks.

regards DaveP.


NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227


 XSL-List info and archive:

Current Thread