Subject: RE: [xsl] xslt 2. index-of, nodes From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 4 Jul 2003 10:44:35 +0100 |
> > > > <xsl:for-each-group select="loc" > > > group-by="concat(@hl, '+', @side, > '+', @pos)"> > > > ... > > > </xsl:for-each-group> > > except I can't. > Error at xsl:for-each-group on line 54 of file:/C:/sgml/files/mu2.xsl: > A sequence of more than one item is not allowed here I can't see what's failing here, I don't think it's either of the expressions shown, because the select expression is allowed to select a sequence (obviously) and the concat() expression is guaranteed to return a singleton. Improving the locatability of run-time type errors is high on my priority list, I recognize that it's often very difficult at present. > > > Again, I haven't followed the thread, but note that the big > difference > > between these two constructs is that the value of position() is > > different in the two cases. You get the same groups, but in > the first > > case they are "hierarchically" numbered, and in the second > case, the > > numbering is "flat". > > what do you mean by 'hierarchical' numbering please Mike? The > number would only relate to the last group? e.g. if it was > (imagining)1.2.6.4 I'd only get the 4 when asking for > position() ? Is that it? > I thought you'd probably follow up on that (sigh). Suppose you do <xsl:for-each select="address" group-by="continent"> <xsl:variable name="p1" select="position()"/> <xsl:for-each select="current-group()" group-by="country"/> <xsl:variable name="p2" select="position()"/> <xsl:for-each select="current-group()" group-by="town"/> <xsl:variable name="p3" select="position()"/> <xsl:for-each select="current-group()"> <xsl:variable name="p4" select="position()"/> <xsl:value-of select="p1, p2, p3, p4" separator=", "/> then the output is going to be something like 1, 1, 1, 1 1, 1 ,1, 2 1, 1, 1, 3 1, 1, 2, 1 1, 1, 2, 2, 1, 2, 1, 1 1, 2, 1, 2 etc: in other words, each address will be associated with a contintent number, a country number within the continent, a town number with the country, and an address number within the town. But if you do <xsl:for-each-group select="address" group-by="string-join((continent, country, town), '#')"> <xsl:variable name="p1" select="position()"/> <xsl:for-each select="current-group()"> <xsl:variable name="p2" select="position()"/> Then you only have access to two numbers: a unique number for each town in the world, and the number of the address within the town. So the two solutions differ in the numbering capabilities they offer, even though they are both capable of grouping addresses by town. Does that make it clearer? Michael Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xslt 2. index-of, nodes, David . Pawson | Thread | RE: [xsl] xslt 2. index-of, nodes, David . Pawson |
[xsl] RuntimeException : Programmer, Simon Kelly | Date | RE: [xsl] FW: externalise common W3, Michael Kay |
Month |