Subject: RE: [xsl] key match and x-path problems From: "Kevin Jones" <kjjones@xxxxxxxxxxxx> Date: Mon, 22 Apr 2002 23:29:57 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] key match and x-path problems, Ahmad J Reeves | Thread | RE: [xsl] key match and x-path prob, Ahmad J Reeves |
RE: [xsl] making html output for ap, Hunsberger, Peter | Date | [xsl] REPOST: Applying Templates to, Kunal H. Parikh |
Month |