|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: key match and x-path problems
> 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
|
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
|






