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

double condition syntax

Subject: double condition syntax
From: marina <marina777uk@xxxxxxxxx>
Date: Sat, 7 Feb 2004 04:51:25 -0800 (PST)
xsl condition syntax
Hi,

With the following xml snippet, I wrote an xslt
stylesheet to count the number of messages that go to
either the same or different locations.

--------------------------------------------
xml snippet

<LOG>
   <DIRECT>
      <COMM_TYPE> PAGETELL </COMM_TYPE>
      <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE>
      <CHARACTER_ID> 10010 </CHARACTER_ID>
      <LOCATION_ID> 24488 </LOCATION_ID>
      <TARGET_CHAR_ID> 18735 </TARGET_CHAR_ID>
      <TARGET_CHAR_LOCATION_ID> 24488
</TARGET_CHAR_LOCATION_ID>
      <MESSAGE> hello </MESSAGE>
      </DIRECT>
   <DIRECT>
      <COMM_TYPE> PAGETELL </COMM_TYPE>
      <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE>
      <CHARACTER_ID> 10010 </CHARACTER_ID>
      <LOCATION_ID> 24488 </LOCATION_ID>
      <TARGET_CHAR_ID> 18735 </TARGET_CHAR_ID>
      <TARGET_CHAR_LOCATION_ID> 24488
</TARGET_CHAR_LOCATION_ID>
      <MESSAGE> hello </MESSAGE>
      </DIRECT>
   <DIRECT>
      <COMM_TYPE> PAGETELL </COMM_TYPE>
      <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE>
      <CHARACTER_ID> 76555 </CHARACTER_ID>
      <LOCATION_ID> 43222 </LOCATION_ID>
      <TARGET_CHAR_ID> 18735 </TARGET_CHAR_ID>
      <TARGET_CHAR_LOCATION_ID> 77799
</TARGET_CHAR_LOCATION_ID>
      <MESSAGE> goodbye </MESSAGE>
      </DIRECT>
   </LOG>
--------------------------------------------------
the xslt

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

  <xsl:output method="text"/>
  
  
  <xsl:variable name="NL" select="'&#xA;'"/>
  
  <xsl:variable name="vTotalSent"
                  select="count(LOG/*/MESSAGE)"/>
  
  <xsl:variable name="vNumNotSame"
		select="count(LOG/*[number(TARGET_CHAR_LOCATION_ID)
!= number(LOCATION_ID)])"/>

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

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

</xsl:stylesheet>

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

Produces the following output.

The total number of messages sent was: 3 The total
number of messages sent to a different location was 1
The total number of messages sent to the same location
was 2


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

I need to add a second condition to variable
'vNumNotSame' that also checks to see if the MESSAGE
was the same as the previous sibling MESSAGE, and if
so NOT to count it.

So with the above snippet the new output should be

The total number of messages sent was: 3 The total
number of messages sent to a different location was 1
The total number of messages sent to the same location
was 1  <------- ignored the duplicate.

Thanks for any help,

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.