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

Node test problem with preceding-sibling

Subject: Node test problem with preceding-sibling
From: "Andreas Guther" <aguther@xxxxxxxxxxxxxx>
Date: Tue, 14 Jun 2005 07:54:48 -0700
preceding sibling unique
Hi:

I am trying to build a list of unique entries but somehow I am stuck
with the node test. Seems like I am missing here some basic
understanding.  I tried lots of combination but I am not able to figure
out the correct expression.

The problematic part is the following:

<xsl:variable name="unique-dates"
  select="/REPORT_ACCESS/REPORTS/REPORT
  /DATE[not(preceding-sibling::DATE = .)]"
  />

I am trying to get all unique dates.  Currently I get the following
output:
Unique dates:
05/31/2005
05/30/2005
05/31/2005
05/30/2005

What I would expect is:
Unique dates:
05/31/2005
05/30/2005

I know this is a trivial question, but currently I am stuck and I would
really appreciate some friendly push in the right direction.

Thanks in advance,  Andreas

My test XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text" encoding="UTF-8" indent="no"/>

<xsl:variable name="unique-dates"
  select="/REPORT_ACCESS/REPORTS/REPORT
  /DATE[not(preceding-sibling::DATE = .)]"
  />

<xsl:template match="REPORT_ACCESS">
  <xsl:apply-templates select="REPORTS"></xsl:apply-templates>
</xsl:template>

<xsl:template match="REPORTS">
  <xsl:message>Reports found</xsl:message>
  <!--
  <xsl:apply-templates select="REPORT"></xsl:apply-templates>
  -->

  <xsl:for-each select="$unique-dates">
    <xsl:message><xsl:value-of select="."/></xsl:message>
  </xsl:for-each>

  </xsl:template>

<xsl:template match="REPORT">
  <xsl:value-of select="DATE"></xsl:value-of>
  <xsl:text> - </xsl:text>
  <xsl:value-of select="preceding-sibling::REPORT/DATE"/>
  <xsl:text> || </xsl:text>
</xsl:template>

</xsl:stylesheet>

... and my test XML:

<REPORT_ACCESS>
  <REPORTS>
    <REPORT>
      <REPORT_ID>755600996</REPORT_ID>
      <NAME>Monthly Performance Summary</NAME>
      <DESCRIPTION>Phone Bill Summary::Monthly Performance
Summary</DESCRIPTION>
      <DISPLAY_TEXT>Monthly Performance Summary</DISPLAY_TEXT>
      <DATE>05/31/2005</DATE>
      <VERSION>01/09/2005</VERSION>
      <BATCH_BILL_START_DT>01/02/2005</BATCH_BILL_START_DT>
      <BATCH_BILL_END_DT>01/09/2005</BATCH_BILL_END_DT>
      <EFFECTIVE_DATE>05/31/2005</EFFECTIVE_DATE>
      <EXPIRATION_DATE>05/22/2012</EXPIRATION_DATE>
      <CLIENT_ID>364</CLIENT_ID>
      <CIC_ID>903</CIC_ID>
      <MODE>Premium</MODE>
    </REPORT>
    <REPORT>
      <REPORT_ID>546871065</REPORT_ID>
      <NAME>Monthly Performance Summary</NAME>
      <DESCRIPTION>Phone Bill Summary::Monthly Performance
Summary</DESCRIPTION>
      <DISPLAY_TEXT>Monthly Performance Summary</DISPLAY_TEXT>
      <DATE>05/30/2005</DATE>
      <VERSION>01/16/2005</VERSION>
      <BATCH_BILL_START_DT>01/09/2005</BATCH_BILL_START_DT>
      <BATCH_BILL_END_DT>01/16/2005</BATCH_BILL_END_DT>
      <EFFECTIVE_DATE>05/31/2005</EFFECTIVE_DATE>
      <EXPIRATION_DATE>05/22/2012</EXPIRATION_DATE>
      <CLIENT_ID>364</CLIENT_ID>
      <CIC_ID>903</CIC_ID>
      <MODE>Premium</MODE>
    </REPORT>
    <REPORT>
      <REPORT_ID>563132464</REPORT_ID>
      <NAME>Monthly Performance Summary</NAME>
      <DESCRIPTION>Phone Bill Summary::Monthly Performance
Summary</DESCRIPTION>
      <DISPLAY_TEXT>Monthly Performance Summary</DISPLAY_TEXT>
      <DATE>05/31/2005</DATE>
      <VERSION>01/23/2005</VERSION>
      <BATCH_BILL_START_DT>01/16/2005</BATCH_BILL_START_DT>
      <BATCH_BILL_END_DT>01/23/2005</BATCH_BILL_END_DT>
      <EFFECTIVE_DATE>05/31/2005</EFFECTIVE_DATE>
      <EXPIRATION_DATE>05/22/2012</EXPIRATION_DATE>
      <CLIENT_ID>364</CLIENT_ID>
      <CIC_ID>903</CIC_ID>
      <MODE>Premium</MODE>
    </REPORT>
    <REPORT>
      <REPORT_ID>136207414</REPORT_ID>
      <NAME>Monthly Performance Summary</NAME>
      <DESCRIPTION>Phone Bill Summary::Monthly Performance
Summary</DESCRIPTION>
      <DISPLAY_TEXT>Monthly Performance Summary</DISPLAY_TEXT>
      <DATE>05/30/2005</DATE>
      <VERSION>01/30/2005</VERSION>
      <BATCH_BILL_START_DT>01/23/2005</BATCH_BILL_START_DT>
      <BATCH_BILL_END_DT>01/30/2005</BATCH_BILL_END_DT>
      <EFFECTIVE_DATE>05/31/2005</EFFECTIVE_DATE>
      <EXPIRATION_DATE>05/22/2012</EXPIRATION_DATE>
      <CLIENT_ID>364</CLIENT_ID>
      <CIC_ID>903</CIC_ID>
      <MODE>Premium</MODE>
    </REPORT>
  </REPORTS>
</REPORT_ACCESS>

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

This electronic mail message contains information belonging to PaymentOne,
which may be confidential and/or legal privileged. The information is intended
only for the use of the individual or entity named above. If you are not the
intended recipient, you are hereby notified that any disclosure, printing,
copying, distribution, or the taking of any action in reliance on the contents
of this electronically mailed information is strictly prohibited. If you
receive this message in error, please immediately notify us by electronic mail
and delete this message.
--------------------------------------------------------

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.