Subject: [xsl] Hi Dimitre, question on extra tags. From: Ahmad J Reeves <ahmad@xxxxxxxxxxxxxx> Date: Mon, 28 Jan 2002 11:15:02 +0000 |
Hi Dimitre, If you remember, you sent me this excellent stylesheet that counts the number of mesages sent and received by individuals, but also their movements without duplicates. I have discovered that 20% of my files have extra tags that need parsing as well. So this stylesheet looks for <DIRECT> tags only, but there are also <LOCAL> <GLOBAL> <ADMIN> tags with the same format as <DIRECT>, and they are all siblings at the same level, e.g <LOG> <DIRECT> <LOCAL> <GLOBAL> <ADMIN> <LOG> Is it easy to adjust this stylesheet to account for these extra tags? Many thanks Ahmad <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:key name="kByID" match="DIRECT" use="CHARACTER_ID"/> <xsl:key name="kByTargetID" match="TARGET_CHARACTER_ID" use="."/> <xsl:key name="kLocByCharacter" match="LOCATION_ID[not(. = ../preceding-sibling::DIRECT[1] /LOCATION_ID) ]" use="../CHARACTER_ID"/> <xsl:key name="kLocByValandChar" match="LOCATION_ID" use="concat(., '|', ../CHARACTER_ID)"/> <xsl:variable name="vUniqueCharactersSending" select="LOG/DIRECT[generate-id() = generate-id(key('kByID', CHARACTER_ID )[1] ) ]"/> <xsl:variable name="vUniqueCharactersReceiving" select="LOG/DIRECT/TARGET_CHARACTER_ID [generate-id() = generate-id(key('kByTargetID', . )[1] ) ]"/> <xsl:variable name="vNumCharactersSending" select="count($vUniqueCharactersSending)"/> <xsl:variable name="vNumCharactersReceiving" select="count($vUniqueCharactersReceiving)"/> <xsl:variable name="vTotalSent" select="count(LOG/DIRECT/CHARACTER_ID)"/> <xsl:variable name="NL" select="'
'"/> <xsl:template match="/"> <xsl:for-each select="$vUniqueCharactersSending"> <xsl:value-of select="concat('CHARACTER_ID ',CHARACTER_ID, ' sent ', count(key('kByID',CHARACTER_ID)), ' messages, received ', count(key('kByTargetID',CHARACTER_ID)), $NL )"/> </xsl:for-each> <xsl:for-each select="$vUniqueCharactersReceiving [not(key('kByID', .))]"> <xsl:value-of select="concat('CHARACTER_ID ', ., ' sent 0 messages, received ', count(key('kByTargetID',.)), $NL )"/> </xsl:for-each> <xsl:value-of select="$NL"/> <xsl:value-of select="concat('Number of characters having sent a message: ', $vNumCharactersSending, $NL )"/> <xsl:value-of select="concat('Number of characters having received a message: ', $vNumCharactersReceiving, $NL )"/> <xsl:value-of select="$NL"/> <xsl:value-of select="concat('Total sent: ', $vTotalSent, ', Average sent by a sending character: ', $vTotalSent div $vNumCharactersSending, '
', 'Total received: ', $vTotalSent, ', Average received by a receiving character: ', $vTotalSent div $vNumCharactersReceiving, '
' )"/> <xsl:value-of select="$NL"/> <xsl:value-of select="concat('Room moves by character:', $NL)"/> <xsl:for-each select="$vUniqueCharactersSending"> <xsl:value-of select="concat('Character_ID: ', CHARACTER_ID, ':', $NL )"/> <xsl:for-each select="/LOG/DIRECT/CHARACTER_ID [. = current()/CHARACTER_ID]"> <xsl:if test="not(../LOCATION_ID = ../preceding-sibling::DIRECT [CHARACTER_ID = current()][1]/LOCATION_ID)"> <xsl:value-of select="concat(' ', ../LOCATION_ID, $NL)"/> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] lowercasing all attribute, Steve Ball | Thread | [xsl] Re: Hi Dimitre, question on e, Dimitre Novatchev |
RE: [xsl] RE:read-write same url in, Bryan Rasmussen | Date | RE: [xsl] RE:read-write same url in, Bryan Rasmussen |
Month |