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

preceeding sibling on a first node

Subject: preceeding sibling on a first node
From: marina <marina777uk@xxxxxxxxx>
Date: Sun, 8 Feb 2004 02:25:27 -0800 (PST)
preceeding
Hi,

What does a preceeding sibling check return in the
first child node position?
 
Here's an xml snippet

------------------------------------------
<LOG>
   <DIRECT>
      <LOCATION_ID> 24 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 2799
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> hello </MESSAGE>
   </DIRECT>
   <DIRECT>
      <LOCATION_ID> 24488 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 2455
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> hello </MESSAGE>
   </DIRECT>
   <DIRECT>
      <LOCATION_ID> 23388 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 266
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> hello </MESSAGE>
   </DIRECT>
   <DIRECT>
      <LOCATION_ID> 293 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 293
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> no </MESSAGE>
   </DIRECT>
   <DIRECT>
      <LOCATION_ID> 31132 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 31132
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> no </MESSAGE>
   </DIRECT>
   <DIRECT>
      <LOCATION_ID> 24488 </LOCATION_ID>
      <TARGET_CHARACTER_LOCATION_ID> 24488
</TARGET_CHARACTER_LOCATION_ID>
      <MESSAGE> no </MESSAGE>
   </DIRECT>
 </LOG>

-----------------------------------------------
3 different locations all duplicate messages and 3 the
same locations with duplicate messages.

Here's my stylesheet that tells me how many messages
were sent, which to the same and which to different
locations and removes duplicate messages by checking
the preceeding MESSAGE tag.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>
  
  <xsl:variable name="vTotalSent"
                  select="count(LOG/*/MESSAGE)"/>
  
  <xsl:variable name="vNumNotSame"
    select="count(LOG/*[number(LOCATION_ID) !=
                       
number(TARGET_CHARACTER_LOCATION_ID) and
                       
preceding-sibling::*[1]/MESSAGE !=
                        MESSAGE])"/>
                        
  <xsl:variable name="vNumSame"
    select="count(LOG/*[number(LOCATION_ID) =
                       
number(TARGET_CHARACTER_LOCATION_ID) and
                       
preceding-sibling::*[1]/MESSAGE !=
                        MESSAGE])"/>

   
   <xsl:template match="/">
   
   
   <xsl:text> The total number of messages sent was:
</xsl:text>
   <xsl:value-of select="$vTotalSent"/>
 
   
   <xsl:text> The total number of messages sent to a
different location was </xsl:text>
   <xsl:value-of select="$vNumNotSame"/>
  

   <xsl:text> The total number of messages sent to the
same location was </xsl:text>
   <xsl:value-of select="$vNumSame"/>

   
</xsl:template>

</xsl:stylesheet>
-------------------------------------------

And my output is:

The total number of messages sent was: 6 The total
number of messages sent to a different location was 0
The total number of messages sent to the same location
was 1

--------------------------------

So it correctly removed the duplicates from messages
sent to the same location, but counted 0 for the first
three different locations, instead of 1.

Is it because for the first node there is no
preceeding sibling and therefore nothing to check? I
know its to do with the position of the nodes as I
tried swapping all the same location nodes with the
different location nodes i.e. put the same location
nodes at the top of the file and got the opposite
result.

Kind Regards

Marina





__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

 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.