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

Unique entries from substrings

Subject: Unique entries from substrings
From: "Andreas Guther" <aguther@xxxxxxxxxxxxxx>
Date: Sun, 26 Jun 2005 18:56:28 -0700
xsl unique entries
I am trying to get all unique month-date entries based on a list of
mm/dd/yyyy entries.

I am able to get the unique mm/dd/yyyy entries but I would like to only
get the unique months per year.

I have included a stripped down XML I am reading data from and my test
XSL that should give me the unique values.  From the given data set the
transformation returns now:

"07-2005";"05-2005";"05-2005";

...but what I would like to achieve is:

"07-2005";"05-2005";


I guess the formatting of the date does not work as I expect it.  Is
there another way to find unique entries on a different format than
found in the XML?

Strange to me is that if the formatting would not work, I should see
four entries instead of three.  So something is not working as I think
it should, but I am not able to figure it out.

What do I do wrong????

The XML:

<REPORT_ACCESS>
  <REPORTS>
    <REPORT>
      <!-- not unique in list -->
      <DATE>07/08/2005</DATE>
    </REPORT>
    <REPORT>
      <!-- unique -->
      <DATE>05/08/2005</DATE>
    </REPORT>
    <REPORT>
      <!-- not unique in list -->
      <DATE>07/08/2005</DATE>
    </REPORT>
    <REPORT>
      <!-- unique 05-2005-->
      <DATE>05/09/2005</DATE>
    </REPORT>
    <REPORT>
      <!-- unique 07-2005-->
      <DATE>07/09/2005</DATE>
    </REPORT>
  </REPORTS>
</REPORT_ACCESS>

and the 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"/>
  <!--
    date unformatted
  -->
  <xsl:variable name="unique-dates"
select="REPORT_ACCESS/REPORTS/REPORT/
    DATE[not(../preceding-sibling::REPORT/DATE = .)]"/>
  <!--
    date formatted
    -->
  <xsl:variable name="unique-dates-formatted"
select="REPORT_ACCESS/REPORTS/REPORT/

DATE[not(concat(substring(../preceding-sibling::REPORT/DATE,1,2),'-',sub
string(../preceding-sibling::REPORT/DATE,7,4)) =
concat(substring(.,1,2),'-',substring(.,7,4)))]"/>
  <!--

-->
  <xsl:template match="/REPORT_ACCESS">
    <!-- for testing
    <xsl:copy-of select="$unique-dates-month"/>
    -->
    <xsl:call-template name="build-list-month-year">
      <!-- if used with unformatted list, it works fine as expected -->
      <xsl:with-param name="list" select="$unique-dates-formatted"/>
    </xsl:call-template>
  </xsl:template>
  <!--

  -->
  <xsl:template name="build-list-month-year">
    <xsl:param name="list"/>
    <xsl:for-each select="$list">
      <xsl:text>"</xsl:text>
      <xsl:value-of
select="concat(substring(.,1,2),'-',substring(.,7,4))"/>
      <xsl:text>";</xsl:text>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

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

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.