Subject: RE: [xsl] key match and x-path problems From: Ahmad J Reeves <ahmad@xxxxxxxxxxxxxx> Date: Tue, 23 Apr 2002 11:14:29 +0100 |
Kev, Please ignore reply below as I misread your answer which was of course correct. "the instruction, <xsl:value-of select="concat('STATUS ',CHARACTER_STATUS, ' ',count(key('kByID',CHARACTER_ID)), $NL)"/> Generates 'STATUS 6 3' because key(..) returns a nodeset of these three elements. The <xsl:if ..> is actually redundant since vUniqueCharacters does not contain any duplicates." So how could I then count the correct number of unique statuses ? Ahmad At 09:42 23/04/02 +0100, you wrote: >Hi Kev, > >Thanks for the assistance. > >The first stylesheet is supposed to ignore CHARACTER_ID's that are the same >so in the example below the 3 occurences of STATUS 6 are all the same >person as >they have the same CHARACTER_ID and therefore gives me an innacurate total. > >I wanted the total number of each status in the xml documemt ignoring >duplicte characters, which was why I tried the > ><xsl:if test="not(CHARACTER_ID[. = preceding::CHARACTER_ID])"> > >to count the first occurence of > ><DIRECT> > <COMMUNICATION_TYPE> PAGETELL </COMMUNICATION_TYPE> > <Invoc_serial> 29 </Invoc_serial> > <Serial> 19461910 </Serial> > <USAGE> TELL </USAGE> > <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE> > <CHARACTER_ID> 10010 </CHARACTER_ID> <------ ok we count him here > <CHARACTER_STATUS> 6 </CHARACTER_STATUS> > <LOCATION_ID> 24488 </LOCATION_ID> > <TARGET_CHARACTER_ID> 18735 </TARGET_CHARACTER_ID> > <TARGET_CHARACTER_STATUS> 6 </TARGET_CHARACTER_STATUS> > <TARGET_CHARACTER_LOCATION_ID> 24488 ></TARGET_CHARACTER_LOCATION_ID> > <MESSAGE> %#NF#%wthinks %y%l. o O ( %w%lThinks of a new >prefix/suffix.%y%l ) </MESSAGE> > <TIME> 'Tue, 01 Jan 2002 20:27:50 +0000' </TIME> > </DIRECT> > <LOCAL> > <COMMUNICATION_TYPE> PAGETELL </COMMUNICATION_TYPE> > <Invoc_serial> 29 </Invoc_serial> > <Serial> 19461911 </Serial> > <USAGE> TELL </USAGE> > <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE> > <CHARACTER_ID> 10010 </CHARACTER_ID> <---- same guy so we need to >ignore him here et cetra > <CHARACTER_STATUS> 6 </CHARACTER_STATUS> > <LOCATION_ID> 24488 </LOCATION_ID> > <TARGET_CHARACTER_ID> 23212 </TARGET_CHARACTER_ID> > <TARGET_CHARACTER_STATUS> 3 </TARGET_CHARACTER_STATUS> > <TARGET_CHARACTER_LOCATION_ID> 24485 </TARGET_CHARACTER_LOCATION_ID> > <MESSAGE> %#NF#%wthinks %y%l. o O ( %w%lThinks of a new >prefix/suffix.%y%l ) </MESSAGE> > <TIME> 'Tue, 01 Jan 2002 20:27:50 +0000' </TIME> > </LOCAL> > > > >but my test > ><xsl:if test="not(CHARACTER_ID[. = preceding::CHARACTER_ID])"> > >seems to let them through. Any ideas? > >regards > >Ahmad > > > >At 23:29 22/04/02 +0100, you wrote: >> >>Stylesheet cut... >> >>> Is supposed to produce a list of unique character statuses and how many >>> occurences of them there are. >>> >>> With the xml test below I get: - >>> >>> Number of Unique Characters 4 >>> >>> STATUS 6 3 >>> STATUS 4 1 >>> STATUS 3 1 >>> STATUS 1 1 >>> >>> >>> Instead of >>> >>> Number of Unique Characters 4 >>> >>> STATUS 6 1 >>> STATUS 4 1 >>> STATUS 3 1 >>> STATUS 1 1 >>> >>> As the <xsl:if test="not(CHARACTER_ID[. = >>> preceding::CHARACTER_ID])"> path >>> maybe at fault. >>> >> >>In this case the first result is correct given the XML example. There are >>three cases where >> <CHARACTER_ID> 10010 </CHARACTER_ID> >> <CHARACTER_STATUS> 6 </CHARACTER_STATUS> >> >>are used. So the instruction, >> >> <xsl:value-of select="concat('STATUS ',CHARACTER_STATUS, >> ' ',count(key('kByID',CHARACTER_ID)), >> $NL)"/> >> >>Generates 'STATUS 6 3' because key(..) returns a nodeset of these three >>elements. The <xsl:if ..> is actually redundant since vUniqueCharacters does >>not contain any duplicates. >> >>On the second stylesheet you are referring to a MESSAGE attribute which does >>not exist in the XML document. There is an element by that name but I can't >>see how it is relevant to your stated goal of counting messages where >>TARGET_CHARACTER_LOCATION_ID != LOCATION_ID >> >>Try replacing your vNumNotSame by this and it should fix the problem, >> >><xsl:variable name="vNumNotSame" >>select="count(LOG/*[number(TARGET_CHARACTER_LOCATION_ID) != >>number(LOCATION_ID)])"/> >> >>I have used number() here to force number comparison otherwise you get >>string comparisons which may or may not work depending on formatting. >> >>Regards, >>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 > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] key match and x-path prob, Ahmad J Reeves | Thread | RE: [xsl] key match and x-path prob, Kevin Jones |
Re: [xsl] last(): selecting the las, David Carlisle | Date | AW: [xsl] javascript access to XML , "Braumüller, Hans" |
Month |