RE: [xsl] key match and x-path problems

Subject: RE: [xsl] key match and x-path problems
From: Ahmad J Reeves <ahmad@xxxxxxxxxxxxxx>
Date: Tue, 23 Apr 2002 23:46:15 +0100
Hi Kev,

Many thanks for your prompt reply and correct solution.

I had tried another key that grouped all the statuses but couldn't
see how to bring the two together. Your solution is most elegant.

Many thanks once again,

Ahmad

At 14:34 23/04/02 +0100, you wrote:
>
>> So how could I then count the correct number of unique statuses ?
>>
>> Ahmad
>>
>>
>
>Here is a solution which I think does what you want, i.e. count the number
>of times a CHARACTER_STATUS value is used in the DIRECT, LOCAL, GLOBAL,
>ADMIN elements that are the first to contain any CHARACTER_ID.
>
>The easy way is probably using a second key to map CHARACTER_STATUS values
>to the parent element.
>
><xsl:key name='kByStatus' match="DIRECT | LOCAL | GLOBAL | ADMIN"
>use="number(CHARACTER_STATUS)"/>
>
>You can the use,
>
><xsl:for-each select="$vUniqueCharacters">
>	<xsl:variable name='sameStatus'
>select="key('kByStatus',number(CHARACTER_STATUS))"/>
>	<xsl:variable name='intersect'
>select='$vUniqueCharacters[count(.|$sameStatus)=count($sameStatus)]'/>
>
>	<xsl:if test=".=$intersect[1]">
>		<xsl:text>STATUS </xsl:text>
>		<xsl:value-of select='CHARACTER_STATUS'/>
>		<xsl:text>SUM </xsl:text>
>		<xsl:value-of select="count($intersect)"/>
>		<xsl:value-of select="$NL"/>
>	</xsl:if>
></xsl:for-each>
>
>The loop iterates over the unique characters. To find if this is first with
>a given CHARACTER_STATUS it computes the intersect of the unique characters
>and all the ones which have the same CHARACTER_STATUS value. For there on
>its fairly straight forward to determine if this is first one in that set
>and how many others are in the set.
>
>Kev.
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread