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

RE: Unique entries from substrings

Subject: RE: Unique entries from substrings
From: "Andreas Guther" <aguther@xxxxxxxxxxxxxx>
Date: Mon, 27 Jun 2005 07:52:41 -0700
distinct substrings
Aron:

Thank you very much for your solution and pointing me to the xsl:key
element.

Andreas


-----Original Message-----
From: Aron Bock [mailto:aronbock@xxxxxxxxxxx]
Sent: Sunday, June 26, 2005 8:46 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Unique entries from substrings

Andreas,

You could approach it as a grouping problem, in which case this input:

>
><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>

with this xsl:

<?xml version="1.0" encoding="iso8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:key match="DATE" name="kDates" use="concat(substring(., 1, 2),
substring(., 7))"/>

    <xsl:template match="DATE[generate-id(.) = generate-id(
            key('kDates', concat(substring(., 1, 2), substring(.,
7)))[1])
            ]">
        <xsl:value-of select="concat(substring(., 1, 2), substring(.,
7))"/>
        <xsl:text>&#xa;</xsl:text>
    </xsl:template>

    <xsl:template match="DATE"/>

</xsl:stylesheet>

Yields:

<?xml version="1.0" encoding="UTF-8"?>
072005
052005

Of course, you may have to adjust to include the day, etc ... in which
case
you wouldn't need the substring and concat business.

--A

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

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.