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

RE: A unique distinct problem

Subject: RE: A unique distinct problem
From: "Evan Lenz" <elenz@xxxxxxxxxxx>
Date: Wed, 8 Aug 2001 14:41:16 -0700
shift_date
I think this should work for you:

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

  <xsl:output indent="yes"/>

  <xsl:template match="/">
    <xsl:apply-templates
select="/report/subscriber/location/shift_date[not(@date=preceding::shift_da
te/@date)]">
      <xsl:sort select="@date"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="shift_date">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates
select="/report/subscriber/location/shift_date[@date=current()/@date]/credit
_card[not(@type=preceding::credit_card[../@date=current()/@date]/@type)]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="credit_card">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Evan Lenz
XYZFind Corp.

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Nate
> Sent: Wednesday, August 08, 2001 1:49 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  A unique distinct problem
>
>
> I have found a lot of info on the web, including the archive for this
> list, about selecting distinct nodes using the preceding-sibling axis, and
> what not.  However, I still haven't been able to find a solution for this
> somewhat more convoluted problem.  Given this xml:
>
> <report>
>   <subscriber number="001930">
>     <location number="358107">
>       <shift_date date="09-JUL-01">
>         <credit_card type="Visa">
>         </credit_card>
>         <credit_card type="Switch">
>         </credit_card>
>         <credit_card type="Mastercard">
>         </credit_card>
>       </shift_date>
>       <shift_date date="10-JUL-01">
>         <credit_card type="Visa">
>         </credit_card>
>       </shift_date>
>     </location>
>     <location number="358108">
>       <shift_date date="08-JUL-01">
>         <credit_card type="American Express">
>         </credit_card>
>         <credit_card type="Visa">
>         </credit_card>
>         <credit_card type="Switch">
>         </credit_card>
>         <credit_card type="Mastercard">
>         </credit_card>
>       </shift_date>
>       <shift_date date="09-JUL-01">
>         <credit_card type="Visa">
>         </credit_card>
>         <credit_card type="Mastercard">
>         </credit_card>
>       </shift_date>
>     </location>
>     <location number="358199">
>       <shift_date date="08-JUL-01">
>         <credit_card type="Visa">
>         </credit_card>
>         <credit_card type="Switch">
>         </credit_card>
>         <credit_card type="Mastercard">
>         </credit_card>
>       </shift_date>
>       <shift_date date="10-JUL-01">
>         <credit_card type="American Express">
>         </credit_card>
>         <credit_card type="Visa">
>         </credit_card>
>         <credit_card type="Mastercard">
>         </credit_card>
>       </shift_date>
>     </location>
>   </subscriber>
> </report>
>
> I want to iterate over a list of shift_dates and all the credit cards that
> were used on that date for each subscriber.  So I want a list like this:
>
> <shift_date date="08-JUL-01">
>   <credit_card type="American Express"/>
>   <credit_card type="Visa"/>
>   <credit_card type="Switch"/>
>   <credit_card type="Mastercard"/>
> </shift_date>
> <shift_date date="09-JUL-01"/>
>   <credit_card type="Visa"/>
>   <credit_card type="Switch"/>
>   <credit_card type="Mastercard"/>
> </shift_date>
> <shift_date date="10-JUL-01"/>
>   <credit_card type="American Express"/>
>   <credit_card type="Visa"/>
>   <credit_card type="Mastercard"/>
> </shift_date>
>
> So I basicly want every credit card on each date, but without duplicates
> in the list.  Is this possible with XSLT 1.0?  Or should I wait for
> select-distinct in XSLT 2.0?
>
> Please cc my email, nshafer@xxxxxxxxxxxx, in the reply, I am not
> subscribed to this list.
>
> Thanks,
> Nate
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • A unique distinct problem
    • Nate - Wed, 8 Aug 2001 16:57:27 -0400 (EDT)
      • Evan Lenz - Wed, 8 Aug 2001 17:40:27 -0400 (EDT) <=
        • Nate - Wed, 8 Aug 2001 19:54:40 -0400 (EDT)
          • Evan Lenz - Wed, 8 Aug 2001 19:57:57 -0400 (EDT)

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.