[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: "Kevin Jones" <kjjones@xxxxxxxxxxxx>
Date: Mon, 22 Apr 2002 23:29:57 +0100
kevin path
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

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-2007 All Rights Reserved.