[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: key match and x-path problems

Subject: RE: key match and x-path problems
From: Ahmad J Reeves <ahmad@xxxxxxxxxxxxxx>
Date: Tue, 23 Apr 2002 09:42:07 +0100
number last x.path
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.