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

Re: AW: XPath question concerning distinct-values()

Subject: Re: AW: XPath question concerning distinct-values()
From: Thorsten <xsl-list@xxxxxxxxxxxxx>
Date: Fri, 3 Aug 2012 13:37:49 +0200 (CEST)
Re: AW:  XPath question concerning distinct-values()
Hi Patrick,

the xsl:if statement works fine.
Thanks a lot!


Regards
Thorsen


"Szabo, Patrick (LNG-VIE)" <patrick.szabo@xxxxxxxxxxxxx> hat am 3. August
2012
um 13:26 geschrieben:> Actually just checking for a preceding item with the
same
order-number would probably suffice.
>
> <xsl:template match="item">
> <xsl:if test="not(preceding-sibling::item[order-number =
> current/oder-number])">
> <xsl:value-of select="concat(order-number, ' ', price)">
> </xsl:if>
> </xsl:template>
>
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Developer Patrick Szabo
> Developer
> LexisNexis
> A-1030 Wien, Marxergasse 25
>
> mailto:patrick.szabo@xxxxxxxxxxxxx
> Tel.: +43 1 53452 1573
> Fax: +43 1 534 52 146
>
>
> -----UrsprC<ngliche Nachricht-----
>
> Von: Szabo, Patrick (LNG-VIE) [mailto:patrick.szabo@xxxxxxxxxxxxx]
> Gesendet: Freitag, 03. August 2012 13:22
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: AW:  XPath question concerning distinct-values()
>
> Hi,
>
> You could still use distinct-values and then "iterate" those values and
output
> the desire values from the first item you find with the corresponding
> order-number.
>
> Something like
>
> <xsl:for-each select="distinct-values(/pricelist/item) ">
> <xsl:value-of
>
select="concat(/pricelist/item/order-number[parent::item[order-number=.][1]],
> ' ', /pricelist/item/price[parent::item[order-number=.][1]])">
> </xsl:for-each>
>
> There's probably a more elegant way to do it tough.
>
> Best regards
>
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Developer Patrick Szabo
> Developer
> LexisNexis
> A-1030 Wien, Marxergasse 25
>
> mailto:patrick.szabo@xxxxxxxxxxxxx
> Tel.: +43 1 53452 1573
> Fax: +43 1 534 52 146
>
>
> -----UrsprC<ngliche Nachricht-----
>
> Von: Thorsten [mailto:xsl-list@xxxxxxxxxxxxx]
> Gesendet: Freitag, 03. August 2012 13:14
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff:  XPath question concerning distinct-values()
>
> Hello,
>
> I have a terrible SAP export that looks (simplified) like this:
>
> <pricelist>
> <item>
> <title>Lorem Ipsum Dolor Sit Amet</title>
> <order-number>XY7020280901</order-number>
> <price>12.00</price>
> <unit>50</unit>
> </item>
> <item>
> <title>Some Title</title>
> <order-number>XY9010200901</order-number>
> <price>19.00</price>
> <unit>50</unit>
> </item>
> <item>
> <title>The Same Item With A Different Title</title>
> <order-number>XY9010200901</order-number>
> <price>19.00</price>
> <unit>50</unit>
> </item>
> <item>
> <title>Lorem Ipsum Dolor</title>
> <order-number>XY7010220201</order-number>
> <price>18.00</price>
> <unit>50</unit>
> </item>
> </pricelist>
>
> I want to select each <item> with different <order-number>. Simply
> distinct-values(/pricelist/item) doesn't work because the <title> of
item[2]
> and
> item[3] are different.
>
> My output should look like this:
> XY7020280901 12.00
> XY9010200901 19.00
> XY7010220201 18.00
>
> I'm using XSLT2.0 with Saxon 9.2 PE.
>
> Any ideas?
>
> Many thanks in advance.
>
> Kind regards
> Thorsten

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.