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






