[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xslt 2. index-of, nodes
> > > > <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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|