[Home] [By Thread] [By Date] [Recent Entries]
Hi All,
I have a nested grouping arrangement, simplified (I hope not too much or incorrectly) below in Listing 2. It operates on the xml file simplified in Listing 3. <xsl:value-of select="//List/Item/position()"/>" returns the position of every <Item> in the list. What I want as a result is the position in the <List> of the <SubDiv1>'s parent <Item>. The output I want is in Listing 1a, the output I get is in Listing 1b. Thanks, Mark Listing 1a: desired. <List> <Item> <Heading>1</Heading> <SubDiv1>1</SubDiv1> </Item> <Item> <Heading>2</Heading> <SubDiv1>2</SubDiv> </Item> </List> Listing 1a: actual <List> <Item> <Heading>1</Heading> <SubDiv1>1 2</SubDiv1> </Item> <Item> <Heading>2</Heading> <SubDiv1>1 2</SubDiv> </Item> </List> Listing 2: simplified xsl: <xsl:template match="List"> <List> <xsl:for-each-group select="Item" group-by="Heading" collation="{$sorting-collation}"> <xsl:sort select="current-grouping-key()" collation="{$sorting-collation}"/> <Item> <Heading> <xsl:value-of select="position()"/> <!-- first call --> </Heading> <xsl:for-each-group select="current-group()" group-by="SubDiv1"> <xsl:sort select="current-grouping-key()" collation="{$sorting-collation}"/> <SubDiv1> <xsl:value-of select="//List/Item/position()"/> <!-- second call --> </SubDiv1> ........... </xsl:template> Listing 3: xml <List> <Item> <Heading>Poland</Heading> <SubDiv1>1958</SubDiv1> </Item> <Item> <Heading >Spain</Heading> <SubDiv1>1958</SubDiv1> </Item> </List>
|

Cart



